Chrome OS bash script if statement error

156 Views Asked by At

Im running Chrome OS in dev mode, and I am creating a bash file. The code looks like so:

echo -n "Username: "
read username: "
if [ $username == "mycroft" ]; then
    echo "Correct!"
fi

My problem is that when I run the code in crosh with /bin/sh ./login.sh, after I type in mycroft, I get this error:

[: 4: mycroft: unexpected operator

What did I do wrong?

1

There are 1 best solutions below

1
On

Your problem is on the second line

echo -n "Username: "
read username
if [ $username = "mycroft" ]; then
  echo "Correct!"
fi