* "Parse Error: Condition Expected"
@ 1996-11-03 17:41 DPD
1996-11-03 18:54 ` Bart Schaefer
1996-11-03 18:59 ` Zefram
0 siblings, 2 replies; 3+ messages in thread
From: DPD @ 1996-11-03 17:41 UTC (permalink / raw)
To: zsh-users
Hello there!
(Please mail all destructive comments to /dev/null...I'll get to
those later..Thanks!)
Here is a portion of the entire script.
This module essentially reads my /etc/group file, pulls out all users
(currently domenick, sysop, root) in a particular group (sysop) and
stores them in a variable for later processing.
For logical purposes, the file "~/tmp/.sysop.users.group" in the
following script already contains the extracted list of users from the
sysop group; i.e, when 'cat'ed to the screen, this file contains
data formatted as "domenick,sysop,root".
This portition of the script:
---------------------------------------------------------------
control="start"
integer count=1
until [ $control = "stop" ]
do
user=`cut -d "," -f $count ~/tmp/.sysop.users.group`
if [ $user = "" ] ************************** LINE #48
then
# stop the loop
control="stop"
else
if [ $user = "root" ] *************************LINE #54
then
# Don't include root in the list!
count=$count+1
else
echo "$user " >> ~/tmp/.list.group
count=$count+1
fi
fi
done
new_list=`cat ~/tmp/.list.group`
--------------------------------------------------------------------
Produces this (continous) output (which is ultimately 'kill'ed):
*****************************************
./group.zsh: parse error: condition expected: = [48]
./group.zsh: parse error: condition expected: = [54]
./group.zsh: parse error: condition expected: = [48]
./group.zsh: parse error: condition expected: = [54]
./group.zsh: parse error: condition expected: = [48]
./group.zsh: parse error: condition expected: = [54]
./group.zsh: parse error: condition expected: = [48]
./group.zsh: parse error: condition expected: = [54]
*****************************************
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)
Great! Now how do I write the script to stop processing on this
encounter??? Please feel free to interject your comments/ideas.
One crude(?) idea which quickly comes to mind is to basically using
the 'od -a' command to capture each read and then compare it to the set
value of "0000000 nl"....if they match, then stop the loop...
There has got to be a better way to do this.....
Apparently and rightfully so, this issue is causing the 'parse
error...' in both of the "if" statements within this loop...right??
BTW, I'm running zsh version 3.0.0.
Thanks for all your help!
Dom
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: "Parse Error: Condition Expected"
1996-11-03 17:41 "Parse Error: Condition Expected" DPD
@ 1996-11-03 18:54 ` Bart Schaefer
1996-11-03 18:59 ` Zefram
1 sibling, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 1996-11-03 18:54 UTC (permalink / raw)
To: DPD, zsh-users
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: "Parse Error: Condition Expected"
1996-11-03 17:41 "Parse Error: Condition Expected" DPD
1996-11-03 18:54 ` Bart Schaefer
@ 1996-11-03 18:59 ` Zefram
1 sibling, 0 replies; 3+ messages in thread
From: Zefram @ 1996-11-03 18:59 UTC (permalink / raw)
To: DPD; +Cc: zsh-users
> if [ $user = "" ] ************************** LINE #48
Maybe you mean
if [ "$user" = "" ]
> if [ $user = "root" ] *************************LINE #54
if [ "$user" = "root" ]
-zefram
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1996-11-03 19:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-11-03 17:41 "Parse Error: Condition Expected" DPD
1996-11-03 18:54 ` Bart Schaefer
1996-11-03 18:59 ` Zefram
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).