samedi 13 mars 2021

linux shell script variable "not found"

Just trying to exit a loop once no input is entered at the prompt, but I'm having trouble testing for the value in an if statement?

CODE:

SQL="?";
while true 
do

    if [ "$SQL" == "" ]
    then
        break
    else    
        read -p "SQL: "  SQL
        clear
        php -f sql.php "$SQL"
    fi
    
done

OUTPUT:

sql.sh: 5: [: ?: unexpected operator
SQL: 

Aucun commentaire:

Enregistrer un commentaire