From b96c886c4fd7ce8d58d049da39ffb63e7ce7b927 Mon Sep 17 00:00:00 2001 From: Eric Nielsen Date: Thu, 4 Mar 2021 10:16:42 -0500 Subject: [PATCH] if: actually use if to test a command's success (#5344) Using `{{command}} && {{command1}} || {{command2}}` does not actually work like if, and it's misleading to teach that to users. The difference is that in the above construct, command2 gets executed if command1 fails, which does not happen in a real if as in `if {{command}}; then {{command1}}; else {{command2}}; fi` --- pages/common/if.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pages/common/if.md b/pages/common/if.md index 1844404df9..95108a4843 100644 --- a/pages/common/if.md +++ b/pages/common/if.md @@ -4,7 +4,7 @@ - Echo a different thing depending on a command's success: -`{{command}} && echo "success" || echo "failure"` +`if {{command}}; then echo "success"; else echo "failure"; fi` - Full if syntax: