mirror of
https://github.com/tldr-pages/tldr.git
synced 2025-04-22 06:02:18 +02:00
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`
This commit is contained in:
parent
83b97fc248
commit
b96c886c4f
1 changed files with 1 additions and 1 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
- Echo a different thing depending on a command's success:
|
- 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:
|
- Full if syntax:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue