|
From: | mwoehlke |
Subject: | Re: null command and parameter expansion for "Display error if null or unset" |
Date: | Mon, 31 Jul 2006 12:28:05 -0500 |
User-agent: | Thunderbird 1.5.0.5 (X11/20060719) |
Poor Yorick wrote:
The following line does not perform the "echo" command. : ${FAKEVAR?} || echo hello This seems inconsistent, since the return status is set to one, not to mention that the null command is documented to return a zero exit code. It would be a convenient and concise syntax for acting on unset variables.
'man bash'. The behavior is exactly as documented, particularly the part "... and the shell ... exits". This is consistent because 'exits' means 'don't finish what you were doing' (in this case, '|| echo hello').
What you probably want is: [ "$FAKEVAR" ] || echo hello -- Matthew DOS Attack: See America Online -- my college room mate
[Prev in Thread] | Current Thread | [Next in Thread] |