[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: master a89c86888c4 1/3: Detect developer builds in git worktrees as
From: |
Po Lu |
Subject: |
Re: master a89c86888c4 1/3: Detect developer builds in git worktrees as well |
Date: |
Sat, 30 Sep 2023 19:54:24 +0800 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
Mattias Engdegård <mattias.engdegard@gmail.com> writes:
> 30 sep. 2023 kl. 13.33 skrev Po Lu <luangruo@yahoo.com>:
>
>> test -o is equally non-portable. I will fix that on master.
>
> The Solaris man page suggested that -o would work. Is it in error, or did I
> misread it?
>
> https://docs.oracle.com/cd/E86824_01/html/E54763/test-1.html
It functions on Solaris, but not under other POSIX systems.
(autoconf)Limitations of Builtins mentions:
‘test’
The ‘test’ program is the way to perform many file and string
tests. It is often invoked by the alternate name ‘[’, but using
that name in Autoconf code is asking for trouble since it is an M4
quote character.
The ‘-a’, ‘-o’, ‘(’, and ‘)’ operands are not present in all
implementations, and have been marked obsolete by Posix 2008. This
is because there are inherent ambiguities in using them. For
example, ‘test "$1" -a "$2"’ looks like a binary operator to check
whether two strings are both non-empty, but if ‘$1’ is the literal
‘!’, then some implementations of ‘test’ treat it as a negation of
the unary operator ‘-a’.
Thus, portable uses of ‘test’ should never have more than four
arguments, and scripts should use shell constructs like ‘&&’ and
‘||’ instead. If you combine ‘&&’ and ‘||’ in the same statement,
keep in mind that they have equal precedence, so it is often better
to parenthesize even when this is redundant. For example:
# Not portable:
test "X$a" = "X$b" -a \
'(' "X$c" != "X$d" -o "X$e" = "X$f" ')'
# Portable:
test "X$a" = "X$b" &&
{ test "X$c" != "X$d" || test "X$e" = "X$f"; }
‘test’ does not process options like most other commands do; for
example, it does not recognize the ‘--’ argument as marking the end
of options.
It is safe to use ‘!’ as a ‘test’ operator. For example, ‘if test
! -d foo; ...’ is portable even though ‘if ! test -d foo; ...’ is
not.