The eval builtin command¶
Synopsis¶
eval: eval [arg ...]
Description¶
eval takes its arguments, concatenates them separated by spaces, and executes the resulting string as Bash code in the current execution environment. eval in Bash works in essentially the same way as most other languages that have an eval function. Perhaps the easiest way to think about eval is that it works in the same way as running \'\'bash -c \"bash code...\" \'\'from a script, except in the case of eval, the given code is executed in the current shell environment rather than a child process.
Examples¶
In this example, the literal text within the here-document is executed as Bash code exactly as though it were to appear within the script in place of the eval command below it.
#!/usr/bin/env bash
{ myCode=$(