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?

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
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 Thu, 19 Mar 2020 17:41:59 -0700
Lines 31
Approved bug-bash@gnu.org
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>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1584664932 4234 209.51.188.17 (20 Mar 2020 00:42:12 GMT)
X-Complaints-To action@cs.stanford.edu
Cc John McKown <john.archie.mckown@gmail.com>, bug-bash@gnu.org
To Robert Elz <kre@munnari.OZ.AU>
Envelope-to bug-bash@gnu.org
User-Agent Thunderbird
In-Reply-To <4305.1584111179@jinx.noi.kre.to>
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy]
X-Received-From 173.164.175.65
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <5E741157.50904@tlinx.org>
X-Mailman-Original-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>
Xref csiph.com gnu.bash.bug:16037

Show key headers only | 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