[net.bugs.usg] bug in sh

david@utzoo.UUCP (David Trueman) (10/24/84)

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

adm@cbneb.UUCP (10/27/84)

Just another example of adding features by deleting code!