I am parsing options with `getopts` but would like to handle long-options as
well.
mygetopts ()
{
aggr=()
for arg in "$@"; do
case $arg in
("--context") aggr+=( "-C" ) ;;
(*) aggr+=( "$arg" ) ;;
esac
done
set -- "${aggr[@]}"
local OPTIND OPTARG
local shortopts="C:"
while getopts "$shortopts" arg; do
case $arg in
("C") context="$OPTARG" ;;
(*) break ;;
esac
done
}
But I wonder whether the use of `set -- "${aggr[@]}"` is correct.
Or is the following (using `eval`) more appropriate?
eval set -- "${aggr[@]}"