Is this a bug in sh?
eric.a.olson
mveao at cbnews.ATT.COM
Wed Jul 5 11:50:14 AEST 1989
In article <PAUL.89Jul4155856 at marvin.moncam.co.uk> paul at moncam.co.uk (Paul Hudson) writes:
>
>Consider the two (executable) shell scripts..
>script1 is and script2 is
> echo $0 echo $0
> name=`basename $0` name= `basename $0`
>Go on, tell me I haven't RTFM .... ;-) Then tell me why it's this way.
They both evaluate the basename of their shell -- script1 and script2,
respectively. The first assigns this to the variable $name;
the second, however runs it as yet another command,
in an environment where the variable $name is set to null.
This causes recursion and the spawned shells you mentioned.
fodder
fodder
fodder
More information about the Comp.unix.questions
mailing list