Arguments to 4.3BSD "sh -c" commands are mishandled
Karl Heuer
karl at haddock.UUCP
Tue Dec 16 13:52:40 AEST 1986
[Braces appearing below are used for quoting. --kwzh]
In article <7296 at elsie.UUCP> ado at elsie.UUCP (Arthur David Olson) writes:
>Type in the command { sh -c 'echo $*' a b c d } and note the incorrect
>output: { b c d }.
"That's not a bug, it's a feature!" :-) "a" is being assigned to $0. If you
don't care about $0, use a placeholder: { sh -c 'echo $*' sh a b c d }*.
It would be nice if this were documented, though. I've never seen a man page
for sh that mentions the possibility of giving arguments to a { sh -c }, and
it's been implemented slightly differently in various incarnations.
Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint
*Do not use "-" as the placeholder; argv[0][0]=='-' is magic!
More information about the Comp.bugs.4bsd.ucb-fixes
mailing list