Bourne Shell bug? Have a look..
Brandon S. Allbery KB8JRR
allbery at NCoast.ORG
Wed Jan 23 15:34:18 AEST 1991
As quoted from <1991Jan16.153557.15548 at ms.uky.edu> by morgan at ms.uky.edu (Wes Morgan):
+---------------
| chet at po.CWRU.Edu writes:
| >Paolo Ventafridda writes:
| >
| >$ :
| >$ set "one two three 4"
| >$ if [ "`echo $@ | grep '4'" != "" ]; then
| >$ echo "Four"
| >$ fi
| >$
| >
| >The `standard' AT&T Bourne shell will silently add a missing
| >closing delimiter when it hits EOF. I don't think ksh does,
|
| Hmmmmm.....if it added the delimiter when it hit EOF, wouldn't
| it put it at the end of the script, giving an "unexpected end
| of file" error? I had thought that this might be a precedence
+---------------
Precedence doesn't play a part in it; the " is seen first, so the "word
splitter" scans to the next un-escaped ". Thus, it gets the string:
`echo $@ | grep '4'
When it later scans that string, it discovers the unbalanced ` and inserts one
at the end.
++Brandon
--
Me: Brandon S. Allbery VHF/UHF: KB8JRR on 220, 2m, 440
Internet: allbery at NCoast.ORG Packet: KB8JRR @ WA8BXN
America OnLine: KB8JRR AMPR: KB8JRR.AmPR.ORG [44.70.4.88]
uunet!usenet.ins.cwru.edu!ncoast!allbery Delphi: ALLBERY
More information about the Comp.unix.shell
mailing list