RosettaCodeData/Task/Runtime-evaluation-In-an-environment/UNIX-Shell/runtime-evaluation-in-an-environment.sh
2023-07-01 13:44:08 -04:00

15 lines
220 B
Bash

eval_with_x() {
set -- "`x=$2; eval "$1"`" "`x=$3; eval "$1"`"
expr "$2" - "$1"
}
eval_with_x '
# compute 2 ** $x
p=1
while test $x -gt 0; do
p=`expr $p \* 2`
x=`expr $x - 1`
done
echo $p
' 3 5
# Prints '24'