有一个名为cower 的程序. (cower 是一个 Archlinux AUR 下载器。)
cower -[udhsc] target
我正在编写一个名为 xcower 的 shell 脚本.
xcower -[Syudhsc] target1 target2 target3 ...
xcower取 2 个附加参数 S 和 y。并将剩余的参数传递给 cower。我不知道如何获得剩余参数和目标。
顺便说一句,xcower目标是在 1 个命令中从全新安装的 Arch 安装 AUR 包。
最佳答案
您可以尝试使用 shift
和 OPTIND
变量的组合,例如(不回答)
shift $(($OPTIND - 1))
来自 bash 引用
OPTIND The index of the next argument to be processed by the getopts builtin command (see SHELL BUILTIN COMMANDS below).
shift [n] The positional parameters from n+1 ... are renamed to $1 .... Parameters represented by the numbers $# down to $#-n+1 are unset
关于linux - shell 脚本 : how to use getopts to get last arguments and unhandle arguments,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5602862/