bug-bash
[Top][All Lists]
Advanced

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

Re: Running commands from array in a child script


From: Paul Jarc
Subject: Re: Running commands from array in a child script
Date: Fri, 26 Oct 2007 12:40:25 -0400
User-agent: Gnus/5.11 (Gnus v5.11) Emacs/22.1 (gnu/linux)

bengoavs <bengoavs@yahoo.com> wrote:
> CMDS=("ls -l > /tmp/log")
> ~/child.sh "${CMDS[0]}"
>
> child.sh:
> for i in "$@"
> do
>         if [ "$i" ]; then
>                 echo "$i"
>                 $i

Redirections and other special characters are not treated specially if
they are produced by a variable expansion.  In this case, you want:
  eval "$i"


paul




reply via email to

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