shell 执行过程中确认脚本模板
#!/bin/bash
function confirm() {
echo -e $1
read -r -p "确认继续吗? [Yes/No] " input
case $input in
[yY][eE][sS] | [yY])
$2
;;
[nN][oO] | [nN])
return 0
;;
*)
echo "Invalid input..."
exit 1
;;
esac
}
function test1() {
echo $1
}
BASE_DIR=$(
cd $(dirname $0)
pwd
)
confirm "即将执行xxx" "test1 ${BASE_DIR}"
echo "123"