[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Commands executed with $($prog) do not run properly
From: |
Hans-Georg Bork |
Subject: |
Re: Commands executed with $($prog) do not run properly |
Date: |
Mon, 08 Nov 2010 15:26:10 +0100 |
Hi,
On Mon, 2010-11-08 at 08:51 -0500, Greg Wooledge wrote:
> 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 this is true, then please explain the differences between
$ find /test -type d ! -wholename "/test"
(/test not shown)
and
$ prog='find /test -type d ! -wholename "/test"'
$ echo $prog
find /test -type d ! -wholename "/test"
$ echo "$($prog)"
(/test shown)
(more results in original mail)
> 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....
This were indeed just a simple example, the script where I use this set
a complex find command with several -wholename options and there is also
whitespace and wildcards in them. IMHO I'd need double-quotes with it;
it is also explained that way in the man page of find.
Thanks in advance.
Regards
--hgb