bug-bash
[Top][All Lists]
Advanced

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

Re: Commands executed with $($prog) do not run properly


From: Greg Wooledge
Subject: Re: Commands executed with $($prog) do not run properly
Date: Mon, 8 Nov 2010 08:51:20 -0500
User-agent: Mutt/1.4.2.3i

On Sat, Nov 06, 2010 at 03:09:08AM +0100, Hans-Georg Bork wrote:
> $ prog='find /test -type d ! -wholename "/test"'
> $ echo $prog
> find /test -type d ! -wholename "/test"
> $ echo "$($prog)"
> /test
> /test/c
> /test/b
> /test/d
> /test/a
> $ 

This is an error in your script, not in bash.  You're passing literal
double-quotes as part of an argument to find.  find is therefore looking
for files that have double-quotes in their name.

If you wanted those double-quotes to be interpreted by bash, you would
have to use eval.  Of course, your double-quotes are not actually
necessary in this example.  Chances are you've obfuscated the original
code....

What you're attempting *appears* to fall into this category:

  http://mywiki.wooledge.org/BashFAQ/050 -- I'm trying to put a
  command in a variable, but the complex cases always fail!

I'd suggest reading that (and avoiding eval).



reply via email to

[Prev in Thread] Current Thread [Next in Thread]