22 Ekim 2021 Cuma tarihinde Stephane Chazelas via austin-group-l at The Open Group <austin-group-l@opengroup.org> yazdı:
> 2021-10-22 01:11:43 -0500, Rob Landley via austin-group-l at The Open > Group: > [...] > > > > Where system("-blah") fails because sh is insane legacy weirdness > and it turns > > > > out that -c does NOT take an argument. So: > > > > > > > > sh -c -i "echo hello" > > > > > > > > Works, which that means "sh -c -potato" tries to parse -potato as an > option, and > > > > fails. > [...] > > Note that if it was even insaner legacy, it would be fine. > > In the Bourne shell, only the first argument was considered for > options. > > In the Bourne shell originally, you'd have had to write: > > sh -fc 'echo hello' > > Or > > sh -cf 'echo hello' > > to interpret "echo hello" while the f option is enabled. sh -c > -f 'echo hello' would interpret -f with "echo hello" in $0. > > 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. 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. -- Oğuz