01-27-2009
139,
15
Join Date: Jan 2009
Last Activity: 19 September 2016, 9:39 AM EDT
Posts: 139
Thanks Given: 13
Thanked 15 Times in 13 Posts
[[ ]] is the "extended test facility"
word splitting and file name generation are not done inside the extended test facility, and therefore there is less need to quote.
You did not quote ${CHECK} in your first example and I think that is the difference. I don't know exactly what happens in the shell, but I think that the shell basically tried to use the '-n' test w/o an operand, possibly, because w/o quotes it treated the contents of ${CHECK} as a file name and could not find it (since it was null) which might be why the "not found" came up.
I quoted it using the test facility [ ] (not extended) which prevented file name expansion and allowed the result of ${CHECK} to be tested against the '-n' operator, and it worked fine, but w/o quotes I reproduced your errror.
I'm more familiar with ksh and HP-UX's "posix shell" (based on ksh) and the [[ ]] facility use is encouraged over [ ].
Last edited by rwuerth; 01-27-2009 at 06:28 PM..
Reason: changed abosulte wording to reflect that I'm unsure on some points. This way someone might verify or correct me.