bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Are there any plans for more readable, modern syntaxes for If statem


From: John McKown
Subject: Re: Are there any plans for more readable, modern syntaxes for If statements?
Date: Fri, 13 Mar 2020 06:59:56 -0500

On Thu, Mar 12, 2020 at 4:01 PM Eli Schwartz <address@hidden>
wrote:

> On 3/12/20 3:00 PM, Vaidas BoQsc wrote:
> > Are there any plans to have alternative, a more modern C or D like
> syntaxes
> > for IF statements, While loop and the like in Bash?
> >
> > Would it be better to just make a new shell and command language similar
> to
> > Bash instead of adding these alternatives?
>
> $ if (true) { echo success; }
> bash: syntax error near unexpected token `{'
> $ alias {=then }=fi
> $ if (true) { echo success; }
> success
>

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.



>
> Is this what you wanted? :p
>
> Personally, I don't really see the problem. I already need to remember
> how to do these in multiple languages, and any of them look weird from
> the context of another language. Can you describe why you feel the bash
> syntax isn't "modern enough"?
>
> What would you propose for backwards compatibility, and what is the
> likelihood people will actually use a different syntax to do the same
> thing, which only works on very new systems? What about POSIX sh scripts?
>
> This seems like a fairly big proposal for something I'm not even seeing
> a definite argument as being actually wrong.
>
> --
> Eli Schwartz
> Arch Linux Bug Wrangler and Trusted User
>
>

-- 
People in sleeping bags are the soft tacos of the bear world.
Maranatha! <><
John McKown


reply via email to

[Prev in Thread] Current Thread [Next in Thread]