You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
James Guthrie edited this page Apr 21, 2015
·
11 revisions
Remove surrounding $() to avoid executing output.
Problematic code:
if $(which "false"); then echo "true"; fi
Correct code:
if which "false" >/dev/null >2&1; then echo "true"; fi
Rationale:
If the $() subshell produces an output it will be evaluated by the if statement, this could result in the execution of the output, which will result in different behaviour than intended.