FS#21759 - [filesystem] /etc/profile, test -a
Attached to Project:
Arch Linux
Opened by Taylan Ulrich B. (taylanub) - Saturday, 20 November 2010, 12:45 GMT
Last edited by Pierre Schmitz (Pierre) - Monday, 22 November 2010, 18:30 GMT
Opened by Taylan Ulrich B. (taylanub) - Saturday, 20 November 2010, 12:45 GMT
Last edited by Pierre Schmitz (Pierre) - Monday, 22 November 2010, 18:30 GMT
|
Details
Using '-a' in 'test ...' aka '[ ... ]' is discouraged;
behaviour is not fully standardized.
Using multiple tests with && and || is always safe. |
This task depends upon
Why not just require POSIX conformance as a minimum? That way [] and $() can be used.
There is a section about "XSI-conformant" systems, talking about more complex rules defining the behaviour of -a and -o, and those might just work, but there is simply no objective advantage of those over using the _simple_ and safe-to-work && and ||.
Remember that 'test' is usually builtin and calling it many times won't cause slow-down. Even if /usr/bin/test would be called a bunch of times, it would probably be a nanosecond difference anyway.
Using /usr/bin/test explicitly doesn't make sense in my opinion. POSIX conformance as a minimum must obviously be, again in my opinion. Also, using && and || will of course work with /usr/bin/test too, so once again, it's just fail-proof.