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: Pierre Gaston
Subject: Re: Commands executed with $($prog) do not run properly
Date: Mon, 8 Nov 2010 09:14:42 +0200

On Sat, Nov 6, 2010 at 6:12 AM,  <address@hidden> wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: i486
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i486' 
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i486-pc-linux-gnu' 
> -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL 
> -DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2 
> -Wall
> uname output: Linux main.hgbhome.net 2.6.18-4-686 #1 SMP Wed May 9 23:03:12 
> UTC 2007 i686 GNU/Linux
> Machine Type: i486-pc-linux-gnu
>
> Bash Version: 3.2
> Patch Level: 39
> Release Status: release
>
> Description:
>
> Hi,
>
> if a program ist started with $($prog) the output is different from <command>
> or even $(<command>). Example with find (excluding a directory from search):
>
> $ ls -l /test
> total 16
> drwxrwxr-x 2 hgb hgb 4096 Nov  6 02:14 a
> drwxrwxr-x 2 hgb hgb 4096 Nov  6 02:14 b
> drwxrwxr-x 2 hgb hgb 4096 Nov  6 02:14 c
> drwxrwxr-x 2 hgb hgb 4096 Nov  6 02:14 d
> $ find /test -type d ! -wholename "/test"
> /test/c
> /test/b
> /test/d
> /test/a
> $ echo "$(find /test -type d ! -wholename "/test")"
> /test/c
> /test/b
> /test/d
> /test/a
> $ 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
> $
>
> As seen above /test ist shown when $prog is executed.
>
> I see the same behavior with
> GNU bash, version 3.2.25(1)-release (x86_64-redhat-linux-gnu) (CentOS)
> GNU bash, version 3.2.39(1)-release (i486-pc-linux-gnu) (debian)
>
>
> I understand that the above looks crazy and not like a problem out of real 
> life
> .... I had to use find to crawl through a huge tree and remove only a few 
> files
> in it. I came across the above problem when feeding an array with the output 
> of
> find; I fixed it for now by removing the unwanted entries from the output
> array.
>
> Thanks in advance for looking into this.
>
> Regards
>        -- hgb
>
>
>
>
your problem is there:

$ prog='find /test -type d ! -wholename "/test"'

The quotes around " " are quoted, they are not special to the shell
anymore, only the literal, non quoted quotes
are special to the shell.
When you later execute $prog, the " " are not removed, they are no
more special than the other literal chars.

check this http://mywiki.wooledge.org/BashFAQ/050



reply via email to

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