Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] sh bug



> $ cat >a
> a
> b
> x
> $ sh -c 'while read a; do if [ $a = "b" ]; then exit 1; fi; echo $a; done < a; echo done'
> a
> done
> $ ksh -c 'while read a; do if [ $a = "b" ]; then exit 1; fi; echo $a; done < a; echo done'
> a

What is the bug?  The exit only ends the while loop?  Or the parser is 
susceptible to obfuscation?

I'm no shell wizard, but this looks obfuscated.  Using "a" as the name of 
the file, the contents of the first line of the file, the name of the 
variable, and the echoed output is obfuscatory.  So is using "done" as the 
last echo string, since it is the same as the end of the while loop.  
Finally, putting it all on one line doesn't make it any easier.  So, I 
wonder what the root problem is.

11011011


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links