我想了解以下命令的作用
set -- "$@" "-h"
gnu手册说
--
If no arguments follow this option, then the positional parameters are unset.
Otherwise, the positional parameters are set to the arguments, even if some
of them begin with a ‘-’.
不过,我无法从这样的描述中获取太多有用的信息。
据我了解,以下附加-h
到函数参数列表中。
set -- "$@" "-h"
但是,以下内容实际上如何替换--help
为-h
等。
printf '%s\n' "$*"
for arg in "$@"; do
shift
printf '%s\n' "--> arg: $arg"
case "$arg" in
"--Version") set -- "$@" "-V" ;;
"--usage") set -- "$@" "-u" ;;
"--help") set -- "$@" "-h" ;;
"--verbosity") set -- "$@" "-v" ;;
*) set -- "$@" "$arg" ;;
esac
done