Bug in the Bourne shell

cosell at BBN-LABS-B.ARPA cosell at BBN-LABS-B.ARPA
Fri Jul 6 23:32:27 AEST 1984


From:  Bernie Cosell <cosell at BBN-LABS-B.ARPA>

AFter struggling some in trying to debug a shell script, I discovered that the
source of my trouble was what seems to be a bug in the Bourne shell.  Both our
4.2 and our V7 Bourne shells act the same way:

The problem is with '"$@"'.  This construct is claimed to expand to
'"$1" "$2" ... "$n"'.  Unfortunately, it seems just to throw away null args.
That is, if your args are, say, "a", "b c ", and "d", then, as I would have
expected, when I do 'nextprogram "$@"', nextprogram correctly is fed three
args, the second of which is "b c ".  Just right.... BUT... if your args are
"a", "", and "d", then when you do 'nextprogram "$@"', nextprogram ends up with
only TWO args - the "a" and the "d", with the null arg just gone.

Thanks
   /Bernie
   cosell at bbn-unix



More information about the Comp.unix.wizards mailing list