Shell | type eval |
zsh | eval is a shell builtin |
bash | eval is a shell builtin |
dash | eval is a special shell builtin |
tcsh | eval is a shell builtin |
eval is a special shell builtin |
eval
命令用于执行动态拼接而成的Shell
命令。
eval COMMAND_STRING
eval $(cat xx.sh)
commandStr="node";
if [ "$(node --version | sed s/v//g | cut -d . -f 1)" -gt 8 ]; then
commandStr="$commandStr --experimental-modules xx.mjs";
else
commandStr="$commandStr xx.js"
fi
eval "$commandStr"