1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00
cde/docs/ksh/functions/getopt.txt
Jon Trulson c9b8687604 Squashed 'cde/programs/dtksh/ksh93/' content from commit 66e1d4464
git-subtree-dir: cde/programs/dtksh/ksh93
git-subtree-split: 66e1d44642
2021-06-26 14:53:01 -06:00

28 lines
488 B
Text

function getopt
{
typeset c optstring=$1 options= sep=
shift
while getopts $optstring c
do case $c in
[:?])
exit 2
;;
*)
options="$options$sep-$c"
sep=' '
if [[ $optstring == *$c:* ]]
then options=" $options $OPTARG"
fi
#then print -rn -- " -$c" "$OPTARG"
#else print -rn -- " -$c"
;;
esac
done
print -rn -- "$options"
if [[ ${@:$OPTIND-1} != -- ]]
then print -rn -- " --"
fi
if [[ -n ${@:$OPTIND} ]]
then print -r -- " ${@:$OPTIND}"
fi
}