While writing a fairly simple shell script, I've tried to compare two strings.
I was using /bin/sh
instead of /bin/bash
, and after countless hours of debugging, it turns out dash (which is actually dash) can't handle this block of code:
if [ "$var" == "string" ]
then
do something
fi
What is a portable way to compare strings uding /bin/sh? I know I can always do the opposite by using !=, but I am wondering about a cleaner, portable way.