[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] about the definition of `eval`
From: |
Andy Chu |
Subject: |
Re: [Help-bash] about the definition of `eval` |
Date: |
Sat, 17 Aug 2019 14:47:14 -0700 |
It means "concatenate with a space"
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#eval
As with all builtins, this is performed as a SEPARATE step after word
evaluation. Just like 'echo', which joins its arguments with a space,
the behavior of 'eval' can be confusing if you don't understand how
words are evaluated. And words that are arrays make things even more
complex because there are several ways to reference them.
Andy
On Sat, Aug 17, 2019 at 1:48 PM Peng Yu <address@hidden> wrote:
>
> Hi,
>
> It is not clear what "Combine" means in `help eval`.
>
> eval: eval [arg ...]
> Execute arguments as a shell command.
>
> Combine ARGs into a single string, use the result as input to the shell,
> and execute the resulting commands.
>
> Exit Status:
> Returns exit status of command or success if command is null.
>
> For example, I see this.
>
> $ eval echo '1 b'
> 1 b
> $ x=(echo '1 b')
> $ eval "${x[*]}"
> 1 b
>
>
> So `eval "${x[@]}"` is essentially the same as `eval "${x[*]}"` for
> any array `x` in bash?
>
> --
> Regards,
> Peng
>