Lots of UNIX versions let you start a script file this way:
#!/bin/sh
That executable file will always be read by a Bourne shell. If some versions of UNIX you use don't
understand
#!
(
44.4
)
, here's how to start your scripts:
|| |
#!/bin/sh export PATH || exec /bin/sh $0 $argv:q |
---|
If a Bourne shell reads that line (that is, if the
#!/bin/sh
succeeded), the
export
PATH
command will succeed and the rest of the command line will be skipped. If a C shell reads the line, it will print the error
export: Command not found
. Then it will run
exec /bin/sh $0 $argv:q
. The
exec
(
45.7
)
replaces the C shell with a Bourne shell, passes it the name of the script file in
$0
, and passes a quoted list of the command-line arguments from
$argv
:q
(
9.6
)
.
-