From: Thomas 'PointedEars' Lahn on
Sven Mascheck wrote:

> Chris F.A. Johnson wrote:
>> On 2010-07-12, Kenny McCormack wrote:
>>> Chris F.A. Johnson <cfajohnson(a)gmail.com> wrote:
>>> ...
>>>> Avoid -a and -o; use && and || [...]
>>>>
>>> Why?
>>>
>> I can't cite chapter and verse OTTOMH, but I recall seeing an Open
>> Group recommendation about not using -a and -o.
>
> In the posix description of the "test" command these features are
> marked as "obsolescent".

No, they are not. BTW, the word you were looking for was "obsolete", but
that does not apply here, too.

> Strictly conforming applications shall not use them, and they might be
> removed in a future version of posix.

Complete, utter nonsense. The section "Future Directions" of the `test'
command in SUSv3 (2004) says exactly "None."

> The informative section "application usage" explains that some
> expressions are ambiguous depending on the specific expressions
> being used.

But it refers to user-supplied input, and does NOT mark those features as
obsolete. or "obsolescent".

> A drastic example,
> especially if the input is not well known:
>
> test -n "$a" -a -n "$b" || echo at-least-one-is-empty
>
> with
> a==; b=x

No programmer in their right mind would do that. Users might provide such
values (hence "user-supplied"), but that is the only occasion they can be
expected.

Your From header is as invalid as your POSIX "knowledge". Please fix both.

--
PointedEars
From: Janis Papanagnou on
Chris F.A. Johnson schrieb:
> On 2010-07-12, Kenny McCormack wrote:
>> In article <8a15fuFhq1U1(a)mid.individual.net>,
>> Chris F.A. Johnson <cfajohnson(a)gmail.com> wrote:
>> ...
>>> Avoid -a and -o; use && and ||:
>>>
>>> if [ $last_seen -gt 0 ] && [ $last_seen -lt $toolate ] ; then
>> Why?
>>
>> (Not that I have any strong opinion on the matter, and I even agree with
>> you, but you usually have some obscure reason for your pronouncements)
>
> I can't cite chapter and verse OTTOMH, but I recall seeing an Open
> Group recommendation about not using -a and -o.

Yes. There's this comment:

:> Unless the application writer knows all the cases that produce input
:> to the script, invocations like:
:>
:> test "$1" -a "$2"
:>
:> should be written as:
:>
:> test "$1" && test "$2"

and also, WRT test \( expr1 -a expr2 \) -o expr3

:> This command is not always portable outside XSI-conformant systems.

In POSIX the -a and -o and the parenthesis are marked as "extensions".

Apparently, there are enough reasons to avoid those options.

Janis
From: Thomas 'PointedEars' Lahn on
Janis Papanagnou wrote:

> Chris F.A. Johnson schrieb:
>> On 2010-07-12, Kenny McCormack wrote:
>>> In article <8a15fuFhq1U1(a)mid.individual.net>,
>>> Chris F.A. Johnson <cfajohnson(a)gmail.com> wrote:
>>> ...
>>>> Avoid -a and -o; use && and ||:
>>>>
>>>> if [ $last_seen -gt 0 ] && [ $last_seen -lt $toolate ] ; then
>>> Why?
>>>
>>> (Not that I have any strong opinion on the matter, and I even agree with
>>> you, but you usually have some obscure reason for your pronouncements)
>>
>> I can't cite chapter and verse OTTOMH, but I recall seeing an Open
>> Group recommendation about not using -a and -o.
>
> Yes. There's this comment:
>
> :> Unless the application writer knows all the cases that produce input
> :> to the script,

IOW, unless they are providing the input and not the user.

> invocations like:
> :>
> :> test "$1" -a "$2"
> :>
> :> should be written as:
> :>
> :> test "$1" && test "$2"
>
> and also, WRT test \( expr1 -a expr2 \) -o expr3
>
> :> This command is not always portable outside XSI-conformant systems.
>
> In POSIX the -a and -o and the parenthesis are marked as "extensions".

| expression1 -a expression2
| [XSI] [X>
| True if both expression1 and expression2 are true; otherwise, false.
| The -a binary primary is left associative. It has a higher precedence
| than -o. <X]
| expression1 -o expression2
| [XSI] [X>
| True if either expression1 or expression2 is true; otherwise, false.
| The -o binary primary is left associative. <X]
| [...]
| ( expression )
| [XSI] [X> True if expression is true. False if expression is false.
| The parentheses can be used to alter the normal precedence and
| associativity. <X]

| [...]
| [XSI] [X> Extension <X]
|
| The functionality described is an XSI extension. Functionality marked XSI
| is also an extension to the ISO C standard. Application writers may
^^^^^^^^^^^^^^^^^^^^^^^
| confidently make use of an extension on all systems supporting the X/Open
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
| System Interfaces Extension.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| If an entire SYNOPSIS section is shaded and marked XSI, all the
| functionality described in that reference page is an extension. See
| XSI Conformance [1]

[1]
<http://www.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap02.html#tag_02_01_04>

> Apparently, there are enough reasons to avoid those options.

Apparently, many people like to jump to conclusions.

--
PointedEars
From: Geoff Clare on
Thomas 'PointedEars' Lahn wrote:

> Sven Mascheck wrote:
>
>> Chris F.A. Johnson wrote:
>>> On 2010-07-12, Kenny McCormack wrote:
>>>> Chris F.A. Johnson <cfajohnson(a)gmail.com> wrote:
>>>> ...
>>>>> Avoid -a and -o; use && and || [...]
>>>>>
>>>> Why?
>>
>> In the posix description of the "test" command these features are
>> marked as "obsolescent".
>
> No, they are not.

Yes they are. You are looking at an out-of-date version of the
standard.

> BTW, the word you were looking for was "obsolete", but
> that does not apply here, too.

XBD7 section 1.7.1 Codes:

[OB] Obsolescent
The functionality described may be removed in a future version of
this volume of POSIX.1-2008.

>> Strictly conforming applications shall not use them, and they might be
>> removed in a future version of posix.
>
> Complete, utter nonsense. The section "Future Directions" of the `test'
> command in SUSv3 (2004) says exactly "None."

SUSv3 was superseded by SUSv4 in 2008. Sven was referring to the
current standard, not the out-of-date one you were looking at.

--
Geoff Clare <netnews(a)gclare.org.uk>

From: Kenny McCormack on
In article <tk2ug7-jtg.ln1(a)leafnode-msgid.gclare.org.uk>,
Geoff Clare <geoff(a)clare.See-My-Signature.invalid> wrote:
....
>SUSv3 was superseded by SUSv4 in 2008. Sven was referring to the
>current standard, not the out-of-date one you were looking at.

Don't confuse the pointed out with facts. They only confuse and annoy him.

--
> No, I haven't, that's why I'm asking questions. If you won't help me,
> why don't you just go find your lost manhood elsewhere.

CLC in a nutshell.