In article <flgxq-8n...@gated-at.bofh.it> you write:
>Package: bash
>Version: 4.1-3
>Severity: normal
>
>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):
>
[...]
>$ echo $prog
>find /test -type d ! -wholename "/test"
>$ echo "$($prog)"
>/test
>/test/c
>/test/b
>/test/d
>/test/a

Your command
  $ echo "$($prog)"
has some irrelevant complexity.

The $() collects the output and the echo re-outputs it, and the quotes
prevent whitespace reorganization, so the whole thing is equivalent to:

  $ $prog

And it's doing what it should do (the same as posh, dash, ksh, etc). After
$prog is expanded, the resulting command line contains quotation marks, but
the line is not reparsed to make use of them, so they are taken as regular
characters.

In other words, with prog='find /test -type d ! -wholename "/test"' the
following are equivalent:
  $ $prog
  $ find /test -type d ! -wholename \"/test\"

When you want a variable's value to be parsed as if it was shell input, you
need to use eval.

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

-- 
Alan Curry



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to