From ffebea16e14fec5e1793469c9830485efdf0758b Mon Sep 17 00:00:00 2001 From: Daniel Heater Date: Fri, 19 Apr 2019 10:01:53 -0500 Subject: [PATCH] Add example for testing equality --- SC2039.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/SC2039.md b/SC2039.md index 8b943a2..f0cbff6 100644 --- a/SC2039.md +++ b/SC2039.md @@ -23,6 +23,26 @@ a="$(printf '%b_' ' \t\n')"; a="${a%_}" # protect trailing \n Want some good news? See http://austingroupbugs.net/view.php?id=249#c590. +### Testing Equality + +`==` operator is not supported in POSIX `sh` + +Bash: + +```Bash +if [ "$a" == "$b" ]; then + echo "equal" +fi +``` + +POSIX: + +```sh +if [ "$a" -eq "$b" ]; then + echo "equal" +fi +``` + ### `$"msgid"` Bash: