2021-10-22 12:43:11 +0300, Oğuz:
[...]
> > So system() was broken when sh started accepting more than one
> > option argument.
> >
> 
> I wouldn't say broken. This is rather an academic case, I don't see why
> anyone would name a utility that way (`-potato'/`+potato'), I don't know a
> single utility that is named that way either.
[...]

FWIW,


zsh has a "-" builtin command (to run a command with it's
argv[0] prefixed with a "-").

$ zsh -c '- ps -f'
zsh: bad option string: '- ps -f'
$ zsh -c -- '- ps -f'
UID          PID    PPID  C STIME TTY          TIME CMD
chazelas  728758   93970  0 18:01 pts/8    00:00:00 /bin/zsh
chazelas  729347  728758  0 18:02 pts/8    00:00:00 -ps -f

(from 1990; less useful now that most shells support a -l /
--login to achieve the same effect as "- sh").

Note that it's not only about the command's name, one could want
to do:

system("++dir++/script.py blah");

> The standard should note this corner case and encourage developers to
> implement `system()' to behave as if `sh -c -- command' were called, and
> leave it at that.
[...]

Yes, it should make sure that system("any shell code") correctly
gets a shell to interpret that code.

-- 
Stephane

  • Re: Posix issue 8 p... Rob Landley via austin-group-l at The Open Group
    • Re: Posix issu... Geoff Clare via austin-group-l at The Open Group
      • Re: Posix ... Rob Landley via austin-group-l at The Open Group
        • Re: Po... Vincent Lefevre via austin-group-l at The Open Group
          • Re... Rob Landley via austin-group-l at The Open Group
            • ... Vincent Lefevre via austin-group-l at The Open Group
      • Re: Posix ... enh via austin-group-l at The Open Group
    • Re: Posix issu... Stephane Chazelas via austin-group-l at The Open Group
      • Re: Posix ... Oğuz via austin-group-l at The Open Group
        • Re: Po... Stephane Chazelas via austin-group-l at The Open Group

Reply via email to