Multiple arguments on a #! line
byron at theclarkfamily.name
Fri Jan 5 23:22:46 MST 2007
I'm hoping someone can explain why #! lines seem to act strangely with
more than one argument to the provided executable. Here's a little
example to show what I mean.
I wrote the following simple C program and compiled it to /tmp/test.
main(int argc, char **argv)
/* print out the args */
for (i = 0; i < argc; ++i)
fprintf(stderr, "[%d] %s\n", i, argv[i]);
Nothing too complicated there, it should just print the arguments it
receives on the command line, in fact, here is an example run:
$ /tmp/test -u -tt foo.sh
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.
#!/tmp/test -u -tt
Here's what happens when I run test.sh:
 -u -tt
So, _why_ are the command line arguments being combined into a single
ps - The real background for this is that I wanted to pass two arguments
to python on the #! line and was getting errors about invalid options.
ruby shows the same kind of behavior with more than one option. Just to
fan the usual plug flames, perl does some kind of magic and handles this
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
Url : http://plug.org/pipermail/plug/attachments/20070105/8c68ce8e/attachment.bin
More information about the PLUG