bug-bash
[Top][All Lists]
Advanced

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

problem with conditional syntax


From: mrkiwi
Subject: problem with conditional syntax
Date: Tue, 14 Nov 2006 01:01:45 -0800 (PST)

I am trying to write the code for this psudo code;

function askYN{
    echo "continue?"
    read the response into $response
}

#set some variables
dothisalways="true"
dothisoptional="false"

if [ $dothisalways ] || [ askYN "Do the compulsory thing?" ]
then
    echo "This is always done because dothisalways is set to true"
fi

if [ $dothisoptional ] || [ askYN "Do the optional thing?" ]
then
   echo "This is done if the variable is set to true (no prompt) OR variable
set to false and user answered Y at prompt" 
else
   echo "This is done if the variable is set to false AND user answered N at
prompt"
fi

This is what i have so far, but it complains (i think) because of the
parameters passed into askYN. 
I think i need to somehow bracket them

if [ askYN "Blah" -eq 0 ] && [ $response == "yes" ]
then
        echo "Doing it"
else
        echo "Not doing it."
fi




can anyone help me?
-- 
View this message in context: 
http://www.nabble.com/problem-with-conditional-syntax-tf2628098.html#a7333742
Sent from the Gnu - Bash mailing list archive at Nabble.com.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]