Mailing List Archive


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

Re: [tlug] sh bug



>>>>> "JDB" == J David Beutel <jdb@example.com> writes:

    >> $ 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

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

I was afraid I would have to explain :( But I though it'd be JC :)

sh interprets exit inside the while loop (only if it's fed from stdin)
as break. This contradicts the man page. Re. obfuscation, I always do
such things on command line, so that I don't have to save a file and
make it executable. No intentional obfuscation was intended. Come on,
it's just one line of code.

Viktor


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links