From f4f0649507ef25f5ae76c8ba983723dd4b63ba43 Mon Sep 17 00:00:00 2001 From: koalaman Date: Thu, 23 Apr 2015 14:15:35 -0700 Subject: [PATCH] Revert 16990d36ab182f7026dcecafa8ec2dfda7ee1b5d...089edfc6e2bbd5eebc4d3d440be22fc4f1488c8c on Template --- Template.md | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/Template.md b/Template.md index bbb2764..598ba3d 100644 --- a/Template.md +++ b/Template.md @@ -1,43 +1,17 @@ -## Remove '$' or use '_=$((expr))' to avoid executing output. +## (Message goes here) ### Problematic code: - i=4 - $(( i++ )) + (Simple example of problematic code) ### Correct code: -Bash, Ksh: - - i=4 - (( i++ )) - -POSIX (assuming `++` is supported): - - i=4 - _=$(( i++ )) - -Alternative POSIX version that does not preserve the exit code: - - : $(( i++ )) + (Simple example of above code, only fixed) ### Rationale: -`$((..))` expands to a number. If it's the only word on the line, the shell will try to execute this number as a command name: - - $ i=4 - $ $(( i++ )) - 4: command not found - $ echo $i - 5 - -To avoid trying to execute the number as a command name, use one of the methods mentioned: - - $ i=4 - $ _=$(( i++ )) - $ echo $i - 5 +(An explanation of why the code is problematic and how the correct code is an improvement) ### Exceptions: -None. \ No newline at end of file +(Cases where the user may choose to ignore this warning, if any.) \ No newline at end of file