tech-userlevel archive
[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index][
Old Index]
Re: '/bin/sh -c' with multiple args
Date: Fri, 5 Dec 2025 00:15:43 +0000
From: Taylor R Campbell <campbell+netbsd-tech-userlevel%mumble.net@localhost>
Message-ID: <20251205001543.90B4A60A8B%jupiter.mumble.net@localhost>
| > 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.
You can set argv[0] of the shell that is running the (usually short)
script that is the command_string. Not of any commands that the shell
runs. Some shells have an option to "exec" which allows that however.
If anyone feels like this would actually have practical uses, we could
implement that easily enough. Usage would typically be
(exec -a foo sleep 30)
The subshell is needed to stop the shell running that command from simply
turning itself into sleep (never does anything further).
If you want to run "sleep" and for some reason call it "wakeup"
you can
ln -s /bin/sleep wakeup
PATH=.:$PATH wakeup
(make the symlink in a directory that is in PATH normally, and you don't
need the PATH= part of it).
| (There's also a call to execl, but it is only for /bin/pwd:
| https://nxr.netbsd.org/xref/src/bin/sh/cd.c?r=1.56#522)
And doesn't ever get used in our environment. Just as the SYSV variant
of execve() (with the loop) doesn't (no sane systems allow execve() to
return EINTR any more).
That code, both places, which never gets compiled, should probably just
be garbage collected). But sh has several historic artefacts like those.
kre
Home |
Main Index |
Thread Index |
Old Index