Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: "Parse Error: Condition Expected"
- X-seq: zsh-users 486
- From: "Bart Schaefer" <schaefer@xxxxxxxxxxxxxxxxxxxxxxx>
- To: "DPD" <dpd@xxxxxxxx>, zsh-users@xxxxxxxxxxxxxxx
- Subject: Re: "Parse Error: Condition Expected"
- Date: Sun, 3 Nov 1996 10:54:47 -0800
- In-reply-to: "DPD" <dpd@xxxxxxxx> ""Parse Error: Condition Expected"" (Nov 3, 12:41pm)
- References: <17404688102380@xxxxxxxx>
- Reply-to: schaefer@xxxxxxx
On Nov 3, 12:41pm, DPD wrote:
} Subject: "Parse Error: Condition Expected"
}
} if [ $user = "" ] ************************** LINE #48
} if [ $user = "root" ] *************************LINE #54
Change those to
if [ "$user" = "" ]
if [ "$user" = "root" ]
and your parse errors will go away.
} After some searchin', I used the "od -a 'filename'" command to look at
} the output each time the loop went through. I found that the last
} read was storing an 'nl' in the variable "user" - which I hypothesized
} to mean 'new line' (correct me if I'm wrong).
} (BTW, the first line of the od output is: 0000000 nl)
There's no "nl" stored in $user -- there's an empty string stored in it.
The "nl" is an artifact of how you ran "od" as far as I can tell.
} Apparently and rightfully so, this issue is causing the 'parse
} error...' in both of the "if" statements within this loop...right??
What's causing the parse error is that $user is empty, so zsh sees
if [ = "" ]
You have to put quotes around the variable reference to turn an empty
variable into an empty string for parsing purposes.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.nbn.com/people/lantern
Messages sorted by:
Reverse Date,
Date,
Thread,
Author