lundi 6 décembre 2021

Bash if-statement gets stuck

I get this loop but for some reason, the if conditional get stucks. The while loop works perfectly.

The inputs are those:

name0="Car name 1"

name1="Car name 2"

name2="Car name 3"
        echo $name0
        echo $name1
        echo $name2
while [ $exit -eq 0 ]
do
    if [ "$name1" = "$name2" ]
    then
    exit=1
        name1="`shuf -n 1 cars.csv | cut -d";" -f1`"
        name1c=`echo $name1 | cut -d" " -f1`
        salir=1
    else
        :
    fi
done

It outputs somethink like this (without #):

Car name 1

Car name 2

Car name 3
#

And gets stuck in the #, I can enter more text but it does nothing.

Aucun commentaire:

Enregistrer un commentaire