[wellylug] Newbie starting BWBasic - Linz

michael at diaspora.gen.nz michael at diaspora.gen.nz
Mon May 2 10:30:07 NZST 2005


Andrew Stephen writes:
>then you'll need the shebang.  It's the same for any interpreter, not
>just shell (as you may have gathered).

Not quite.

    michaelrlt$ uname -a
    Linux michaelrlt 2.6.11-1-k7 #1 Fri Feb 11 14:16:27 UTC 2005 i686
    GNU/Linux
    michaelrlt$ cat > foo
    echo bar
    michaelrlt$ chmod 755 foo
    michaelrlt$ perl -e "exec '/home/michaelr/foo'"
    bar

/bin/sh will be tried if the kernel can't find an interpreter -- see
"man 3 execve":

    If the header of a file isn't recognized (the attempted execve returned
    ENOEXEC),  these  functions will execute the shell with the path of the
    file as its first argument.  (If this attempt fails, no further search-
    ing is done.)

    ...

    FILES
	   /bin/sh

Of course, on my system:

    michaelrlt$ ls -l /bin/sh
    lrwxrwxrwx  1 root root 4 2005-03-31 13:06 /bin/sh -> dash

So, yes, you can eliminate those nasty #! lines if you just want to use
the shell; but it's very very bad practice, and don't do that.
    -- michael.




More information about the wellylug mailing list