Commit Graph

6 Commits

Author SHA1 Message Date
d44677b913 shebang.req (ShebangReq): fix the check for absolute pathname (ALT#23716) 2010-07-03 00:23:03 +00:00
7b74686984 shebang.req (ShebangReq): ensure that interpreter is specified as an absolute pathname (ALT#20096) 2010-07-01 16:14:06 +00:00
Alexey Tourbin
5afc5290c7 shebang.req: fixed typo in description, spotted by Slava Semushin 2008-10-02 16:04:18 +00:00
Alexey Tourbin
d0c2f92f05 shebang.req: validate argc and <CR>
1) In Linux, execve(2) does not split shebang arguments, which implies
that effectively only one argument can be passed to the interpreter.
However, some interpreters, esp. perl, can do a magic here, which is
to split its arguments.

2) Neither /usr/bin/env can split arguments, and no magic is possible
at all.

3) Interpreter path (or name) must not end with <CR>, otherwise execve
(resp. /usr/bin/env) is deemed to fail.  However, some interpreters,
esp. perl, can strip trailing <CR> in its command line options.
2008-09-14 13:17:22 +04:00
Alexey Tourbin
47bd8eff65 shebang.req: don't read the whole script
$ (echo '#!/usr/bin/perl'; cat /dev/zero) |sed -n '1s|^#![[:space:]]*/|/|p;q'
/usr/bin/perl
$
2008-04-01 15:33:19 +04:00
Alexey Tourbin
2fc12ef2fa factored shebang.req
This is the dependency generator for #! lines.
shebang.req.files makes sure that only executable scripts are processed.

Here is why I chose the "shebang" name.

From Jargon File (4.3.1, 29 Jun 2001) [jargon]:

  shebang /sh*-bang/ n. The character sequence "#!" that frequently
     begins executable shell scripts under Unix. Probably derived from "shell
     bang" under the influence of American slang "the whole shebang"
     (everything, the works).

$ cd /usr/lib/perl5/pod
$ grep -i sharpbang *
perltoc.pod:C<shar>, C<sharpbang>, C<shmattype>, C<shortsize>, C<shrpenv>, C<shsharp>,
$ grep -i shebang *
perl58delta.pod:The command-line options -s and -F are now recognized on the shebang
perlbs2000.pod:BS2000 POSIX doesn't support the shebang notation
perlfaq3.pod:batch file and codify it in C<ALTERNATE_SHEBANG> (see the
perlfaq7.pod:line in your perl script (the "shebang" line) does not contain the
perlfaq7.pod:where you expect it so you need to adjust your shebang line.
perlfaq8.pod:but my shebang line is not the path to perl, so the shell runs the
perlglossary.pod:=item shebang
perljp.pod: "shebang"ѹǡJperlѤscriptΤۤȤɤѹʤѲǽȻפޤ
perlplan9.pod:such as "#!/usr/local/bin/perl". This is known as a shebang
perlplan9.pod:shebang path from config information located in Plan 9
perlport.pod:sub-systems do not support the C<#!> shebang trick for script invocation.
perlport.pod:OS/390 will support the C<#!> shebang trick in release 2.8 and beyond.
perlrun.pod:C<ALTERNATE_SHEBANG> (see the F<dosish.h> file in the source
perltoc.pod:serialization, server, service, setgid, setuid, shared memory, shebang,
perlwin32.pod:Perl scripts on UNIX use the "#!" (a.k.a "shebang") line to
$
2007-03-11 15:00:24 +03:00