bug in sh(1) set command ?
David Trueman
david at utzoo.UUCP
Thu Oct 25 02:00:06 AEST 1984
In the Sys5 sh(1), the `set' built-in can be used with `--' as the first
argument, meaning "end of flags", which is handy when your arguments that
follow may start with `-'. It seems logical that `set --' would set the
argument list to nothing, and $# to 0. This behaviour can be quite handy
at times, for example in the following:
set -- `look $word`
case $# in
0)
echo "Nothing found." >&2
;;
1)
;;
*)
echo "Ambiguous word." >&2
;;
esac
This code fragment would not work in the Sys5 shell, as `set --' does nothing.
Can anyone see any use for the current behaviour?
The "fix" for this is easy: in "xec.c", just delete `IF argc > 1' from the
following code fragment.
case SYSSET:
IF a1
THEN INT argc;
argc = options(argn,com);
IF argc>1
THEN setargs(com+argn-argc);
FI
ELIF ((COMPTR) t)->comset==0
THEN /*scan name chain and print*/
namscan(printnam);
FI
--
David Trueman @ U of Toronto Zoology
{allegra,ihnp4,linus,decvax}!utzoo!david
More information about the Net.bugs.usg
mailing list