lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | CMD_SET="gawk gcc bison flex pkg-config" |
| 4 | PACKAGE_SET=("gawk" "build-essential" "bison" "flex" "pkg-config") |
| 5 | RET_VALUE=0 |
| 6 | |
| 7 | function checkCmd() |
| 8 | { |
| 9 | cmd=$1 |
| 10 | i=$2 |
| 11 | which $cmd > /dev/null 2>&1 |
| 12 | if [ $? -eq 0 ]; then |
| 13 | echo "check command $cmd ok" |
| 14 | else |
| 15 | echo "[ERROR]check command $cmd fail, Maybe run [ sudo apt-get install ${PACKAGE_SET[i]} ] to install" |
| 16 | return 1 |
| 17 | fi |
| 18 | } |
| 19 | |
| 20 | i=0 |
| 21 | for item in $CMD_SET;do |
| 22 | checkCmd $item $i |
| 23 | if [ $? -ne 0 ]; then |
| 24 | RET_VALUE=1 |
| 25 | fi |
| 26 | let "i=i+1" |
| 27 | done |
| 28 | |
| 29 | exit $RET_VALUE |
| 30 | |