In this Bash Shell script I like to check if the length of the string is zero. In that case the script should echo an error message and exit.
dbname="ssss"
dbuser=""
if [ -z "$dbname"]
then
echo "DB name is not specified!"
exit
fi
if [ -z "$dbuser"]
then
echo "DB user is not specified!"
exit
fi
If dbname is "" it works as expected. But if it has some value and I was expecting to see it exit at the next conditional, I get this error message:
Script.sh: line 4: [: missing `]'
DB user is not specified!
Why the error message?