3 ms·
Do you know the priority in this? [ -e "${target}" ] && echo "Getting information about ${target}" && stat "${target}" || echo "Failed to stat file." EDIT: Wh
by torstenvl 3y ago
Do you know the priority in this?
[ -e "${target}" ] && echo "Getting information about ${target}" && stat "${target}" || echo "Failed to stat file."
EDIT: What about the || die("...") pattern in Perl?
Or the fact that the glyphs in || are visually lower than the glyphs in &&?
Or that "and" comes before "or" in the expression "and/or"?
- pavlov 3y agoShell scripting sucks, but that’s hardly news. If I really have to touch a bash script, I just assume nothing works like I might expect from proper programming languages despite any surface similarity, and google every construct with sweat drops dripping down my face. ChatGPT has made the process somewhat more tolerable.
- PhilipRoman 3y agoThe shell command is very readable. a && b && c is a common idiom for "stop if any step fails". In the shell language && and || are more like control flow concepts, rather than binary operators. And a && b || c is a universal "ternary operator" (with one minor deviation) idiom across many languages, not just the shell