The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Sort command - strange behaviour miwinter UNIX for Advanced & Expert Users 16 05-29-2008 04:19 AM
TEST command amatuer_lee_3 Shell Programming and Scripting 4 05-09-2008 04:36 AM
a strange message when executing the sort command marwan UNIX for Dummies Questions & Answers 3 04-27-2007 04:32 AM
the TEST command marwan UNIX for Dummies Questions & Answers 2 04-23-2007 03:51 PM
Strange error message with regex test... fgilain Shell Programming and Scripting 4 05-31-2006 06:52 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 11-02-2007
Registered User
 

Join Date: Jul 2007
Location: Cloud 9
Posts: 70
test command looks strange...

I just ran into this today, and don't know what to make of it...
Code:
if test x$SERVER = x
then
        echo $USAGE
        exit 1
fi
I know what everything in there does, except for the 'x' jazz...
Reply With Quote
Forum Sponsor
  #2  
Old 11-02-2007
Registered User
 

Join Date: Jan 2007
Posts: 2,965
Quote:
Originally Posted by jjinno View Post
I just ran into this today, and don't know what to make of it...
Code:
if test x$SERVER = x
then
        echo $USAGE
        exit 1
fi
I know what everything in there does, except for the 'x' jazz...
It is effecitvely doing

Code:
if test "$SERVER" = ""
then
     ....
rather than using quotes, it prefixes an x to the string to ensure it's not an empty string argument. Where it falls down of course is if there is a space in $SERVER.
Reply With Quote
  #3  
Old 11-02-2007
Registered User
 

Join Date: Jul 2007
Location: Cloud 9
Posts: 70
hahahaha... of course, the obvious answer escapes me.

I didn't even think of it as concatenation till you mentioned that.

Thank you
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 07:10 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0