Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!david From: david@utzoo.UUCP (David Trueman) Newsgroups: net.bugs.usg Subject: bug in sh(1) set command ? Message-ID: <4528@utzoo.UUCP> Date: Wed, 24-Oct-84 12:00:06 EDT Article-I.D.: utzoo.4528 Posted: Wed Oct 24 12:00:06 1984 Date-Received: Wed, 24-Oct-84 12:00:06 EDT Organization: U of Toronto Zoology Lines: 40 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