From 5655e240fe1a85637d522500b6b5a20e95982695 Mon Sep 17 00:00:00 2001 From: koalaman Date: Fri, 19 Jan 2018 11:50:15 -0800 Subject: [PATCH] Updated SC2193 (markdown) --- SC2193.md | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/SC2193.md b/SC2193.md index c506c7b..6fe1fea 100644 --- a/SC2193.md +++ b/SC2193.md @@ -3,17 +3,19 @@ ### Problematic code: ```sh -[[ "{$var}" == "value" ]] # Swapped around $ and { -[[ "$(cmd1) | cmd2" == "42" ]] # Ended with ) too soon -[[ "$var " == *.png ]] # Trailing space +[ $var+1 == 5 ] # Unevaluated math +[ "{$var}" == "value" ] # Swapped around $ and { +[ "$(cmd1) | cmd2" == "42" ] # Ended with ) too soon +[[ "$var " == *.png ]] # Trailing space ``` ### Correct code: ```sh -[[ "${var}" == "value" ]] # Correct variable expansion -[[ "$(cmd1 | cmd2)" == "42" ]] # Correct command substitution -[[ "$var" == *.png ]] # No trailing space +[ $((var+1)) == 5 ] # Evaluated math +[ "${var}" == "value" ] # Correct variable expansion +[ "$(cmd1 | cmd2)" == "42" ] # Correct command substitution +[[ "$var" == *.png ]] # No trailing space ``` ### Rationale: