I was running some Bash conditional scripts and discovered if I run this:
#!/bin/bash
read foo
if [[ foo -eq 1 ]]; then
echo "A"
fi
if [[ foo -eq 2 ]]; then
echo "B"
fi
The conditionals work fine under Bash 4.2.25 without the use of $foo. Why does this work without referencing the variable with a $?
bashbuilt-in command (compared with either the Bourne shell or the POSIX shell) and it has been decreed that variables do not need to be prefixed with$in this one context.