Edmond Rodriguez on 16 Sep 2010 13:26:12 -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 16:26: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 :content-transfer-encoding; bh=TnhSakGZHOl0JYFSL0sQSak+ntnoqQ8J015bh06whC0=; b=If5dhiWXgoiaRXbTQL9g+0ps2mYlKzejdf50tqqBN3uawWT/VPitKMmAQvf/G7FBF7 +STzjR9hwS0fivN+jxf3XgFGh3WJMdAD2pEQtrxTqf8004eixspqmJt11FEj0A5LgDqi AMQoRt3b8Wu9wXFT6FPZNEvF0/WIz3FoyppuY=
  • 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 3:54 PM, sean finney > eval cat $FILE1 $VCIDS > $FILE2
> though this will fail miserably if FILE1/FILE2/VCIDS contain quotes, shell
> metacharacters, word-splitting characters, etc.  so that's a "B-" answer :)

Well, I may be repeating something you covered in the links, but would
this be a simple solution to possible issues?

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?

Sorry if any redundancy in reply.  I just was thinking about this one
issue for now.

* export SOMENAME="abc'def'g"
* echo $SOMENAME

*eval echo $SOMENAME
abcdefg     <---- this is missing single quotes.

*eval "echo \$SOMENAME"
abc'def'g    <----- single quotes as expected.
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