我尝试创建一个 post-checkout git hook并拥有一个将运行composer update
和php artisan migrate:refresh
的bash脚本,因为我'我刚刚开始使用bash脚本我无法弄清楚为什么我的脚本没有执行“运行迁移”#39;一部分?
#!/bin/bash
exec < /dev/tty
while true; do
read -p "Run Composer Update[Y/n]: " yn
case $yn in
[Yy]* ) composer update; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
while true; do
read -p "Run Migrations[Y/n]: " yn
case $yn in
[Yy]* ) php artisan migrate:refresh; break;;
[Nn]* ) exit;;
* ) echo "Please answer yes or no.";;
esac
done
答案 0 :(得分:1)
在“否”选项中使用break
代替exit
#!/bin/bash
exec < /dev/tty
while true; do
read -p "Run Composer Update[Y/n]: " yn
case $yn in
[Yy]* ) composer update; break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done
while true; do
read -p "Run Migrations[Y/n]: " yn
case $yn in
[Yy]* ) php artisan migrate:refresh; break;;
[Nn]* ) break;;
* ) echo "Please answer yes or no.";;
esac
done