linux-tutorial/codes/shell/demos/statement/select-demo.sh

15 lines
340 B
Bash
Raw Normal View History

2017-11-17 17:06:52 +08:00
#!/usr/bin/env bash
PS3="Choose the package manager: "
select ITEM in bower npm gem pip
do
echo -n "Enter the package name: " && read PACKAGE
case ${ITEM} in
2019-10-10 08:56:31 +08:00
bower) bower install ${PACKAGE} ;;
npm) npm install ${PACKAGE} ;;
gem) gem install ${PACKAGE} ;;
pip) pip install ${PACKAGE} ;;
2017-11-17 17:06:52 +08:00
esac
2019-03-01 10:36:45 +08:00
break # 避免无限循环
2017-11-17 17:06:52 +08:00
done