I've seen posts similar to this, where the "command not found" error is thrown because of white space errors in the if statement.
I can't find my white space errors. Where are they? What else could it be?
Basically, if I run test.sh (below) without a flag, the terminal starts shouting rude obscenities like, "Command not found". If I use a flag, it plays nice. I don't want to bribe bash with flags all the time. It's not good for it's long term health.
This is in test.sh:
verbose='false'
aflag=''
bflag=''
sflag=''
files=''
while getopts 'absf:v' flag; do
    case "${flag}" in
        a) aflag='true';;
        b) blag='true' ;;
        s) sflag='true' ;;
        f) files="${OPTARG}" ;;
        v) verbose='true';;
        *) error "Unexpected option ${flag}" ;;
    esac
done
# ======= Below this is where the error gets thrown
if "$sflag" ;
then
  echo "okay" ;
fi
# ======= end error throwing code 
echo "end" # this prints just fine
I run the above script with
$ bash test.sh
and then I get back
test.sh: line 17: : command not found
end
Will someone please give me advice on how to talk bash into behaving rationally?
I'm using a Mac (I don't know if that makes a difference).

if [[ -n $sflag ]]; thento check if the variable is not null or -z to check if it is.if [ "x$flags" = x ]; then echo empty ; else echo not empty ; fi