On Fri, Jan 05, 2007 at 11:22:46PM -0700, Byron Clark wrote: > Now, I should be able to use this in a #! line to "run" a script, so I > wrote the following script that does absolutely nothing and called it > test.sh and made it executable. <snip> > > #!/tmp/test -u -tt > > Here's what happens when I run test.sh: > > $ ./test.sh > [0] /tmp/test > [1] -u -tt > [2] ./test.sh > > So, _why_ are the command line arguments being combined into a single > argument? >
Most Unix systems[1] will only parse a single option, in a very unintelligent way: the option passed is the first non-whitespace character until the end of the line. Because of this a #! will lump all the options as one. Try leaving some trailing whitespace, it'll preserve it as well. This is more tradition than anything, apparently POSIX doesn't say anything about handling #! lines. Linux goes the traditional route. Interesting side note, on OS X the kernel handles multiple arguments: $ ./test.sh [0] /Users/spr/test [1] -u [2] -tt [3] ./test.sh That got me mad because I could do what you're wanting to do on my OS X box, but in Linux it kept messing up. Scott [1] From Classic Shell Scripting, O'Reilly -- Scott Paul Robertson http://spr.mahonri5.net GnuPG FingerPrint: 09ab 64b5 edc0 903e 93ce edb9 3bcc f8fb dc5d 7601
pgplERckNI01r.pgp
Description: PGP signature
/* PLUG: http://plug.org, #utah on irc.freenode.net Unsubscribe: http://plug.org/mailman/options/plug Don't fear the penguin. */
