Results 1 to 3 of 3
Hey all,
I have the following code:
syntax="Usage: ${scriptName} [desiredMountPoint] [--noping]"
echo syntax;
I get: Usage: foo.sh [desiredMountPoint] 1
Where does the "1" come from and how is it being ...
- 03-03-2009 #1Just Joined!
- Join Date
- Sep 2008
- Posts
- 7
Variable evaluation problem
Hey all,
I have the following code:
syntax="Usage: ${scriptName} [desiredMountPoint] [--noping]"
echo syntax;
I get: Usage: foo.sh [desiredMountPoint] 1
Where does the "1" come from and how is it being evaulated to it? "[-noping]" displays "[-noping]" just fine. Escaping out the square brackets and/or dashes no longer evaluates the "[--...]", but I have goofy looking output:
"\[\-\-noping\]"....obviously, I don't want that.
What I want:
syntax="Usage: ${scriptName} [desiredMountPoint] [--noping]"
echo syntax;
Usage: foo.sh [desiredMountPoint] [--noping]
Thanks,
Jeff
- 03-03-2009 #2Linux Newbie
- Join Date
- Feb 2009
- Location
- Third ring of Pergatory
- Posts
- 199
- 03-03-2009 #3Just Joined!
- Join Date
- Sep 2008
- Posts
- 7
There's no mounting going on at this point of the script. I just wanted to echo out the syntax of the script for anyone who called it with a "-?" or "--help" argument.
Anyway, I figured it out:
echo $syntax gave me the funky variable eval to "1".
echo "${syntax}" stopped the funky var eval. Everything looks good now.


Reply With Quote
