Re: [PATCH] Linux 2.6: shebang handling in fs/binfmt_script.c

From: Paul Jackson (pj_at_sgi.com)
Date: 02/23/04

  • Next message: David S. Miller: "Re: Intel vs AMD x86-64"
    Date:	Mon, 23 Feb 2004 13:46:10 -0800
    To: Andries Brouwer <aebr@win.tue.nl>
    
    

    Andries Brouwer wrote:
    > If there is such nonblank text then for SysVR4,
    > SunOS, Solaris, IRIX, HPUX, AIX, Unixware, Linux, OpenBSD, Tru64
    > this group consists of precisely one argument.
    > FreeBSD, BSD/OS, BSDI split the text

    Interesting - I notice that 9 Operating Systems, in addition to Linux,
    don't split the optional shebang argument, and 3 do.

    All else equal, I am not enthusiastic about a somewhat arbitrary change
    that could be done either way, that is actually done more often in other
    operating systems the current way, and that potentially affects both
    script files and their interpreters (shells, awk, perl, python, guile,
    tcl, bc, ...).

    I will acknowledge however that if there was a shell or interpreter that
    allowed at most one '-' prefixed option before the path to the script
    file to be interpreted, that that shell or interpreter would be poorly
    coded.

    And, to be truthful, the usual way that I code awk scripts is not as
    a shbang script with an interpreter of awk,

      #!/bin/awk
      BEGIN ...

    but rather as a quoted awk script within a shell script:

      #!/bin/sh
      awk '
        BEGIN ...
      '

    It is then trivial to supply one or several options to 'awk', and
    (as the tclsh man page notes) to cope with possible diverse locations
    along $PATH of the interpreter.

    This is especially useful in the case of awk, since it is not a
    convenient language for many things that are easily done in a shell.
    That is, I don't write awk scripts, so much as I write shell scripts
    that might make use of awk.

    This is a portable habit, that avoids all the afore mentioned
    limitations and inconsistencies in shbang handling.

    -- 
                              I won't rest till it's the best ...
                              Programmer, Linux Scalability
                              Paul Jackson <pj@sgi.com> 1.650.933.1373
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: David S. Miller: "Re: Intel vs AMD x86-64"

    Relevant Pages

    • Re: Script to extract portions of text from a text file
      ... > But your example is not comparing the same command. ... it wouldn't be sent to the shell until you press enter). ... >> behaves differently in a script and at the prompt ... While awk does: ...
      (comp.unix.shell)
    • Re: grep with a variable
      ... it's always better to use an awk variable than try to interleave ... %> shell and awk. ... When you want to use a shell ... commmand-line script, or you can assign it to a variable, and use the ...
      (comp.lang.awk)
    • Re: How can I get the value of a variable from within awk script into shell?
      ... I have to write a bash-shell script to process a file. ... I use in this shell script these awk ... This is more a shell problem than an awk problem. ... in a subshell, and this seems to be your case. ...
      (comp.lang.awk)
    • Re: #! vs : use ?
      ... colon is basically an evaluated commented - a shell builtin for /bin/ ... Configure script knows a lot about *ix history) Configure script. ... doesn't recognise any shebang mechanism. ... interpreter when a file was starting with "#!". ...
      (comp.unix.shell)
    • cron shell scripts Summary
      ... I am fully aware of the Best Practice for shell scripts whereby the ... script I wrote ... This lead me to the incorrect conclusion that the CRON daemon simply ... schedule it into cron which will use its default interpreter: ...
      (SunManagers)