On 2009-07-23 20:56 +0200, Boyd Stephen Smith Jr. wrote: > In <[🔎] h49gnk$6np$1@ger.gmane.org>, Raphael Geissert wrote: >>Alexandre Rossi wrote: >>>> And the script doesn't correctly handle the case where the default file >>>> has been removed (it expects the vars to be always defined). The >>>> Xsession script doesn't handle an unset DEEJAYD_DISPLAYNAME and >>>> DEEJAYD_XAUTHORITY vars either. [ -r ] is evaluated to true. >>> >>> [ -r ] behaves correctly both with bash and sh on my lenny box. Not >>> sure I understand what to do here. >> >>What I meant was that: >>$ foo=/foo/bar; [ -r $foo ] && echo hello world > > Looks normal, assuming /foor/bar doesn't exist on your system. > >>$ unset foo; [ -r $foo ] && echo hello world >>hello world >>$ unset foo; [ -r "$foo" ] && echo hello world >><nothing> > > Both these are required behavior by SUSv2. In the first, you are passing 2 > arguments to the '[' command, after removing the trailing ']' only one > argument remains. In that case the '[' (or test) command is required to > return 0 (succeed) if the argument is non-empty and return non-0 (fail) if > the argument is empty. Raphael surely knows this; what he wanted to say is that the behavior of [ -r $foo ] if foo is unset is probably not intended and therefore [ -r "$foo" ] should be used. Sven
Attachment:
pgpCtX9PPBoCO.pgp
Description: PGP signature