* Martin Simmons schrieb am 04.03.10 um 11:40 Uhr: > >>>>> On Thu, 4 Mar 2010 03:41:36 +0100, Marc Schiffbauer said: > > > > * Phil Stracchino schrieb am 03.03.10 um 20:18 Uhr: > > > On 03/03/10 14:05, Brian Debelius wrote: > > > > Hi, > > > > > > > > Looking at Bacula scripts and other scripts, I see a test for an > > > > empty string performed by adding an 'x' before the variable, and then > > > > comparing this to another string that is just an 'x'. > > > > > > > > The shell test function has a -z string test that returns true if > > > > the > > > > string is empty. > > > > > > > > It appears to me that more people use the 'x' comparison. Is there a > > > > technical reason why one would be preferable to the other? > > > > > > > > Why would you do this: > > > > > > > > if [ "x$var" = "x" ]; then > > > > ... > > > > fi > > > > > > > > Instead of this: > > > > > > > > if [ -z $var ]; then > > > > > > more properly: if [ -z "$var" ]; then > > > > > > Why not use > > > > if [ "$var" = "" ]; then > > > > if -z may not be available? > > Because $var might be set to something like ! which would cause a syntax > error.
Thx Martin, I did not know this. Is it only "!" because of some job control stuff or everything that is not [:alnum:]? -Marc -- 8AAC 5F46 83B4 DB70 8317 3723 296C 6CCA 35A6 4134 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Bacula-users mailing list Bacula-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bacula-users