Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!mcvax!ukc!axion!galadriel!pcf From: pcf@galadriel.UUCP (Pete French) Newsgroups: comp.unix.questions Subject: Re: Is this a bug in sh? Message-ID: <282@galadriel.UUCP> Date: 6 Jul 89 12:44:16 GMT References: Distribution: all Organization: RT6115, BTRL, Martlesham Heath, England Lines: 43 From article , by paul@moncam.co.uk (Paul Hudson): > > script1 is and script2 is > > echo $0 echo $0 > name=`basename $0` name= `basename $0` > ^ > Note the space here. > > executing script1 prints "script1" as you would expect. Executing > script2 prints "script2" "script2" ...... and spawns shells at an > enormous rate. > > This is sunos4.0 on a sun3/50. This took some playing to figure out but.... Try this : $ name=abc date Thu Jul 6 13:36:38 WET DST 1989 $ echo $name abc The shell will do the assignment and then run the next command on the line for some unexplained reason. What you have is name= `basename $0` Which will be expanded (correctly) to name= script2 The shell will now assign a blank to name and run script2 - thus re-running the same script. This is what is causing the multiple shells. Why the shell executes a command on the same line as an assignment is beyond me, however. You normally need semicolons to separate commands on the same line in shell. It sems to be acting as if it was... $ name=abc; date -Pete French.