Find the answer to your Linux question:
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 ...
  1. #1
    Just 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

  2. #2
    Linux Newbie
    Join Date
    Feb 2009
    Location
    Third ring of Pergatory
    Posts
    199
    Quote Originally Posted by pgymjp View Post
    Hey all,
    Where does the "1" come from and how is it being evaulated to it?
    Seems like it has to be coming from the mount command returning a one on a failure to mount.

  3. #3
    Just 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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...