> Afaik this is common syntax for if/else based only on the the initial condition
You're right that it's common, but you're wrong saying that it's based only on the initial condition:
$ true && cat nonexistent.txt || echo "shouldn't have run"
cat: nonexistent.txt: No such file or directory
should't have run
> I can't remember where it's documented but I think it requires the do_this part to be a single expression
It's not documented like you said because it's a hack. &&/|| aren't meant to simulate if/else. These aren't expressions either. And they aren't really limited either:
$ true && { echo "true condition ran"; cat nonexistent.txt; } || echo "false condition ran"
true condition ran
cat: nonexistent.txt: No such file or directory
false condition ran
> However, bash pitfalls recommends against using && and || except for very basic logic.
The fact that people end up thinking that it's an ok substitute for if/else syntax is the reason why it's recommended against.
You're right that it's common, but you're wrong saying that it's based only on the initial condition:
> I can't remember where it's documented but I think it requires the do_this part to be a single expressionIt's not documented like you said because it's a hack. &&/|| aren't meant to simulate if/else. These aren't expressions either. And they aren't really limited either:
> However, bash pitfalls recommends against using && and || except for very basic logic.The fact that people end up thinking that it's an ok substitute for if/else syntax is the reason why it's recommended against.