m*****k 发帖数: 731 | 1 【 以下文字转载自 Apple 讨论区 】
发信人: madmonk (madmonk), 信区: Apple
标 题: confused by some shell scripts run on mac
发信站: BBS 未名空间站 (Thu Mar 1 20:54:43 2012, 美东)
my.sh file is like this:
#!/bin/bash
while getopts ":a" opt; do
case $opt in
a) echo "-a was triggered!";;
\?) echo "Invalid option: -$OPTARG" ;;
esac
done
but when I ran it several times, I got diff answers:
mymac me$ . my.sh -abc
-a was triggered!
Invalid option: -b
Invalid option: -c
mymac me$ . my.sh -abc
mymac me$ . my.sh -abc
mymac me$
any mac *nix guy can help explain why it behaves like this? |
|