#!/bin/bash ARGS= `getopt -a -o ah --long install,help -- "$@"` if [ $? != 0 ]; then echo "Terminating..." exit 1 fi eval set -- "${ARGS}" while true do case "$1" in -i|--install) ./install.sh;; -h|--help) ./help.sh;; \?) echo "no args" exit 1;; esac done
@circle33 我已经找到解决方案了,我参考了一下别人的案例,直接去掉 ARGS= `getopt -a -o ah --long install,help -- "$@"` if [ $? != 0 ]; then echo "Terminating..." exit 1 fi eval set -- "${ARGS}" 再更改一下 while 的条件就行