tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

'/bin/sh -c' with multiple args



Hey,

How does '/bin/sh -c' with multiple args actually
work?

The manual page says

sh -c command_string [command_name [argument ...]]

is valid, and should behave as such:

"Read commands from the command_string operand instead
of, or in addition to, from the standard input.
Special parameter 0 will be set from the command_name
operand if given, and the positional parameters (1, 2,
etc.)  set from the remaining argument operands, if
any."

So I would expect

sh -c /bin/sleep whatever 30

to lead to "/bin/sleep 30" being invoked with an argv0
set to "whatever".

However:

$ sh -c /bin/sleep whatever 30
usage: sleep seconds

Now I know that I can do

$ sh -c "/bin/sleep 30"

but the manual page suggests I should be able to set
argv0 of the command as described above, but I don't
see a way of actually doing that.

What am I missing?

-Jan


Home | Main Index | Thread Index | Old Index