1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
#!/bin/sh
# vim: set filetype=sh :
# file: example.eval
# copyright: Bernd Schumacher <bernd.schumacher@hpe.com> (2007-2020)
# license: GNU General Public License, version 3
# description: example that needs to use eval
# see also: example.eval
set -e
set -u
. ./ia
txt="FUN=\"fun()
{
echo \\\"hello\\\"
echo \\\"\\\$1\\\"
}\" # set variable FUN"
#echo "txt=<$txt>"
#eval "$txt"
#echo "FUN=<$FUN>"
#eval "$FUN"
#fun "myname"
eval "$ia_init"
ia_add "echo \"txt=<$<txt>>\""
ia_add "eval \"$<txt>\""
ia_add "echo \"FUN=<$<FUN>>\""
ia_add "eval \"$<FUN>\""
ia_add "fun \"myname\""
ia
|