exe()
当我想显示要运行的命令然后运行该命令时,我会使用一些脚本中调用的函数。我想扩展它,以便运行脚本的人可以选择更新该函数,以便在运行时在每个命令上暂停。我无法让它工作。即它提示“y/N”但什么也不做,所以exe()
没有像我希望的那样在脚本的其余部分重新定义。你能看出这有什么问题吗?如何修复它?
# By default, the following 'exe' will run unattended
# If "y" is chosen, 'exe' is altered to display the command before running it
exe() { printf "\n\n"; echo "\$ ${@/eval/}"; "$@"; }
if [ "$(read -e -p 'Step through each configuration option? [y/N]> '; echo $REPLY)" == [Yy]* ]; then
exe() { printf "\n\n"; echo "\$ ${@/eval/}"; read -p "Any key to continue..."; "$@"; };
fi