help-bash
[Top][All Lists]
Advanced

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

Re: Conditional operator in Shell Arithmetic section


From: Kerin Millar
Subject: Re: Conditional operator in Shell Arithmetic section
Date: Sun, 19 Mar 2023 14:18:17 +0000

On Sun, 19 Mar 2023 13:17:14 +0000
uzibalqa <uzibalqa@proton.me> wrote:

> 
> 
> ------- Original Message -------
> On Sunday, March 19th, 2023 at 10:56 AM, uzibalqa <uzibalqa@proton.me> wrote:
> 
> 
> > ------- Original Message -------
> > On Sunday, March 19th, 2023 at 10:25 AM, Lawrence Velázquez vq@larryv.me 
> > wrote:
> > 
> > > You can find such material elsewhere. Any decent C teaching material
> > > can tell you how ? : works and how you might use it in practice. The
> > > official bash manual is not the only place to learn about such things
> > > (although finding good third-party material is admittedly fraught).
> 
> What changes, additions, clarifications and improvements would you suggest 
> and do?

The POSIX documentation states, "The evaluation of arithmetic expressions shall 
be equivalent to that described in Section 6.5, Expressions, of the ISO C 
standard." [*] By contrast, the bash manual states, "The operators and their 
precedence, associativity, and values are the same as in the C language." The 
latter wording strikes me as being more digestible by its overall audience. On 
the other hand, the POSIX wording makes it rather more clear as to what to look 
for, and where to look within upon finding it, so there may yet be some room 
for improvement there. Further, the SEE ALSO section does not (directly) 
acknowledge the existence of "Shell Command Language" and "ISO/IEC 9899:2018" 
(C) in their capacity as distinct specifications. Perhaps it should.

Otherwise, I'm not sure that there is much else to be done. The operator can be 
trivially searched for in a typical man pager e.g. by using \?.*: as a pattern. 
Perhaps something could be done to make GNU info(1) more easily match the 
relevant section upon searching its index. However, in my experience, the 
majority of capable bash users act as though info doesn't exist, while 
newcomers struggle to use a pager effectively, let alone info. Introducing it 
as the "conditional (ternary) operator" might help some people, though it 
should be borne in mind that it is correctly referred to as the "conditional 
operator", irrespective of its provenance in languages other than sh and C.

[*] 
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap01.html#tagtcjh_15

-- 
Kerin Millar



reply via email to

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