Hi Alex, On 1/4/21 4:13 PM, Alejandro Colomar wrote: > man-pages bug: 211029 > https://bugzilla.kernel.org/show_bug.cgi?id=211029 > > glibc bug: 27143 > https://sourceware.org/bugzilla/show_bug.cgi?id=27143 > > When a command name starts with a hyphen (which is a valid one), > the shell's '-c' option interprets the command name as antoher > option. This can be workarounded by prepending the command name > with a space, as Ciprian pointed out in his bug report. Huh! Well that's weird, of course. So, I think something should be said in the manual page, but perhaps a little less than below. Having a command name that starts with a '-' is a weird corner case, and it's unsurprising (if unfortunate) that it buys you trouble. > Reported-by: Ciprian Dorin Craciun <ciprian.craciun@xxxxxxxxx> > Cc: Florian Weimer <fweimer@xxxxxxxxxx> > Signed-off-by: Alejandro Colomar <alx.manpages@xxxxxxxxx> > --- > > Hi Ciprian, > > If you report a bug to the Austin Group, > please CC linux-man@xxxxxxxxxxxxxxx, > so that we can add the URL and update the BUGS section > if it is ever fixed. > > man3/system.3 | 33 +++++++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/man3/system.3 b/man3/system.3 > index aef40417a..5a9318dec 100644 > --- a/man3/system.3 > +++ b/man3/system.3 > @@ -250,6 +250,39 @@ are not executed. > Such risks are especially grave when using > .BR system () > from a privileged program. > +.SH BUGS > +./" [BUG 211029](https://bugzilla.kernel.org/show_bug.cgi?id=211029) > +./" [glibc 27143](https://sourceware.org/bugzilla/show_bug.cgi?id=27143) Better add the Austin bug URL mnow. > +If the command name starts with a hyphen, > +.BR sh (1) > +interprets the command name as an option, > +and the behavior is undefined > +(See the > +.B \-c > +option in > +.BR sh (1).). s/.)./.)/ > +This behavior is mandated by POSIX. > +To work around this problem, > +prepend the command with a space as below: It's a funny workaround :-). But it seems to work in bash, dash, and zsh. Interestingly. (t)csh doesn't even have the problem. I don't think we need the example below in the manual page (see my comments above), although you could include it in the commit message. Thanks, Michael > +.PP > +.RS 4 > +.EX > +/* system_hyphen.c */ > + > +#include <stdlib.h> > + > +int > +main(void) > +{ > + system(" -echo Hello world!"); > + exit(EXIT_SUCCESS); > +} > +.PP > +.RB "$" " sudo ln \-s \-T /usr/bin/echo /usr/bin/\-echo;" > +.RB "$" " cc \-o system_hyphen system_hyphen.c;" > +.RB "$" " ./system_hyphen;" > +Hello world! > +.EE > +.RE > .SH SEE ALSO > .BR sh (1), > .BR execve (2), > -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/