set 的option 选项中有一个选项相当的迷那就是--选项
英文解释是
An option of a double-dash ("--") signifies the end of an option list. This option is primarily useful when values listed after the options will start with a dash themselves
说白了这个命令选项就是起个偷梁换柱的作用
set -- values
简单解释就是将命令行参数(这里就是指真正传递给shell的参数)替换为set命令的命令行值
例子:set -- $(getopt ab:cd "$@")
就是将原始的命令行参数(就是所谓的“$@”)值替换为getopt所的结果值,
实际上很简单,理解了就是一句话偷梁换柱.
学习linux推荐搭配从shell编程开始,最好有一本很好的书(国外写的最好)不要散兵游勇