Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

"Parse Error: Condition Expected"



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




Messages sorted by: Reverse Date, Date, Thread, Author