Hello everyone!
Let me shed some light into this before wrong conclusions get implemented and
cause more problems to come up.
On Feb 27, 2011, at 11:19 AM, Rob Blake wrote:
>
> As far as I'm aware the "-a" option is not a valid file test parameter in
> Dash, which is the shell invoked by /bin/sh in Ubuntu 10.10. You get the same
> problem if you explicitly invoke the startup script with another shell such
> as Bash, which doesn't have the -a option either.
About the "Bash, which doesn't have the -a option either" part: This is
*wrong*. And please forget about consulting the 'man test' page, as 'test'
(which is identical to '[') is (usually) a shell builtin command and thus its
documentation is to be found using 'help test' or 'man bash'. (If you are
reading 'man bash', enter "/test expr" to jump to the test builtin
documentation.) See the following example terminal session on Mac OS X 10.6:
===============================================
~ $ echo $BASH_VERSION # I'm sure Ubuntu 10.10 which I also use at home uses
a more recent version
3.2.48(1)-release
~ $ help test
test: test [expr]
Exits with a status of 0 (true) or 1 (false) depending on
the evaluation of EXPR. Expressions may be unary or binary. Unary
expressions are often used to examine the status of a file. There
are string operators as well, and numeric comparison operators.
File operators:
-a FILE True if file exists.
-b FILE True if file is block special.
...
~ $ test -a /tmp # builtin, success
~ $ echo $? # checks the exit status of the former command
0
~ $ test -a /tmps # builtin, failure
~ $ echo $?
1
~ $ which test # find the external command documented by 'man test'
/bin/test
~ $ /bin/test -a /tmp
test: /tmp: unknown operand
===============================================
The reason why "you get the same problem if you explicitly invoke the startup
script with another shell such as Bash" is not that the 'setenv.sh' script is
evaluated by Bash, but that it is invoked from its parent script (evaluated or
called by Bash) as just some executable, which means that /bin/sh (and thus
*Dash*), specified using '#!' in the first line, is used to interpret
'setenv.sh' and thus 'test' refers to the *Dash builtin*.
So, to investigate this properly, please run /bin/dash in Ubuntu, then (in that
subshell) 'help test', then 'man dash', to find more information. For
portability, do some Google searches, e.g. using "shell test portable", which
leads to e.g.
http://www.pixelbeat.org/programming/shell_script_mistakes.html#portability
(also mentions dash).
I hope that helps clarify the situation
- Felix
----------------------------------------------------------------
For list details see
http://www.magnolia-cms.com/home/community/mailing-lists.html
To unsubscribe, E-mail to: <[email protected]>
----------------------------------------------------------------