
觉得还是想支持一下长参,就暂时用的getopt, 功能实现了,但发现个奇怪问题
#!/bin/bash
TEMP=`getopt -o c: --long abc: -- "$@"`
echo $TEMP
这样竟也能取到 abc (只打 ab 而不是 abc)
./test-getopt.sh --ab 123
或
./test-getopt.sh --a 123
测试:
$ ./test-getopt.sh --a 123
--abc '123' --
#!/bin/bash
TEMP=`getopt -o c: --long abc: -- "$@"`
echo $TEMP
这样竟也能取到 abc (只打 ab 而不是 abc)
./test-getopt.sh --ab 123
或
./test-getopt.sh --a 123
测试:
$ ./test-getopt.sh --a 123
--abc '123' --
