Edmond Rodriguez on 16 Sep 2010 18:34:14 -0700


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PLUG] Building a command from variables in BASH

  • From: Edmond Rodriguez <erodrig97.list@gmail.com>
  • To: "Philadelphia Linux User's Group Discussion List" <plug@lists.phillylinux.org>
  • Subject: Re: [PLUG] Building a command from variables in BASH
  • Date: Thu, 16 Sep 2010 21:34:07 -0400
  • Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type; bh=467pZMWE5NCG0IQk/gDQG7BotbkFeVxUAOPIeYhhtF4=; b=rF68xVFTQlEPZ0gYPQSEhJ8KBQRoD10i+PMvJOlkzp8vEj+hZ173uDWnce13rrUM+W NXJLZ/IBffCFkX3rqz89CTZG7OwaT7ggCvlOPIYSIF+tArjHFaZnlN/9O84RvNaxrT/n ZR0sG7xu0FYexFcvNercjQWYxCm9PKcufpevw=
  • Reply-to: Philadelphia Linux User's Group Discussion List <plug@lists.phillylinux.org>
  • Sender: plug-bounces@lists.phillylinux.org

On Thu, Sep 16, 2010 at 7:40 PM, sean finney <seanius@seanius.net> wrote:
>> Would escaping the $'s provide a possible simple solution to a not too
>> complex line, if they were serving only as variable holders and did
>> not need to be resolved before the eval?
>
> in that case you wouldn't need eval.
>
> eval foo \$bar
>
> is the same as plain ol'
>
> foo $bar

The original poster had pipes he was dealing with, and to execute that
string, you would need eval.   If there was a var that possibly could
have a quote or something in it, couldn't it be escaped so as to
produce the intended result?


eval "foo \$bar | foo2"

This looks the same as just foo $bar | foo2, but if it's in a variable
(like the poster was doing)  with a string that needs to be parsed
then.....

SOMEVAR="foo \$bar | foo2"
eval "$SOMEVAR"
___________________________________________________________________________
Philadelphia Linux Users Group         --        http://www.phillylinux.org
Announcements - http://lists.phillylinux.org/mailman/listinfo/plug-announce
General Discussion  --   http://lists.phillylinux.org/mailman/listinfo/plug