Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16037

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

From L A Walsh <bash@tlinx.org>
Newsgroups gnu.bash.bug
Subject Re: Are there any plans for more readable, modern syntaxes for If statements?
Date 2020-03-19 17:41 -0700
Message-ID <mailman.175.1584664932.3020.bug-bash@gnu.org> (permalink)
References <CAAJSdjidSYg1yoWC7UbbLUUDF3ug9ekDtkOP7Er-JOjrLoDssQ@mail.gmail.com> <CAB+qc9AAPQbzp92tv-FOR4Kh+2UdZyRwGiPOfNegVqv5UFnU5Q@mail.gmail.com> <f1d0d39d-b6e6-c33e-7463-226f6994b99e@archlinux.org> <4305.1584111179@jinx.noi.kre.to> <5E741157.50904@tlinx.org>

Show all headers | View raw


On 2020/03/13 07:52, Robert Elz wrote:
> That's OK, and at times I have been tempted that way, but it really is
> easier to just do
>
> 	if <some relational test>
> 	then
> 		true_command1
> 		true_command2
> 	else
> 		false_command1
> 		false_command2
> 		false_command3
> 	fi
>   
----
If you need an else clause, then using 'if' makes sense,
but for a simple 1-liner equivalent to C's

  if (bool) truecase;

bash's

  $bool && truecase

is certainly shorter than any if;then;fi case and for a simple 1-liner,
just as clear if not more so.

Being concise was certainly not a design priority as much for shell
as for C.

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: Are there any plans for more readable, modern syntaxes for If statements? L A Walsh <bash@tlinx.org> - 2020-03-19 17:41 -0700

csiph-web