次のコマンドが何をするのか理解したい
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