Alex Duschek
möp
Ich hab hier ein sicher banales Problem, ich fliege immer per exit 4 aus dem Programm, $ERROR bekommt nie den Wert 0. Hat jemand eine Idee, an was das liegen könnte?
Beispielinhalt der .data
Code:
benutzername=passwort
test=test
hallo=hier
Code:
#!/bin/bash -x
extractPasswd()
{
THENAME=$1
ZERO=0
ERROR=1
# read corresponding password
FILE=~/.data
if [ -s $FILE ]; then
cat $FILE | while read LINE; do
USR=${LINE%=*} # extracts the username
PW=${LINE#*=} # extracts the password
# correct user found, exit
if [ "$THENAME" == "$USR" ]; then
ERROR=0
break;
fi
done
fi
# check for errors
if [ $ERROR -ne $ZERO ]; then
exit 4;
fi
}
Zuletzt bearbeitet: