On 3/13/20 7:59 AM, John McKown wrote: > I do things like: > > test <some relational test> && { true_command1;true_command2; : ; } || { > false_command1; false_command2; false_command3; } > > Notice the command : (colon) as the last command in the true. The reason > that I put it there is to guarantee that the $? from the series of > "true_commnds" is 0 (aka "true") so that the commands in the || are not > executed.
OP: "I want readable, modern syntax for If statements, inspired by C." You: "Don't use If, use &&, which doesn't look like a C If either." I'm... not following? I mean, yes, the things which you do are valid bash syntax, and yes, they seem to do what you want them to do, but I don't *really* understand how they tie in to the premise of the thread. In contrast, "abuse parser macros" is a valid if terrible answer to the question of changing the syntax of a bash feature. Something which is otherwise not really an option, since 40-year-old languages do not change fundamental syntax on a whim as though they are, I dunno, perl6. (I am still mindblown that "I want a modern syntax for XXXX" can possibly lead to "imitate C, which is 50 years old and thus astoundingly even less modern than the Bourne shell by an entire decade".) -- Eli Schwartz Arch Linux Bug Wrangler and Trusted User
signature.asc
Description: OpenPGP digital signature