Hello,
set -- -a foo -a bar # for testing while getopts :a: arg; do ...
You can use typical array cryptic emulation with dash for this :) #!/bin/dash main() { local i=0 l= oIFS="$IFS" n= while getopts :a:u:n: arg; do case $arg in a) local l$((i=i+1))="$OPTARG"; l="${l}${l:+ }"'attr="$l'$i\";; n) n=$OPTARG;; esac done shift "$((OPTIND - 1))" IFS=' '; eval set -- $l '"$@"'; IFS=$oIFS echo '$@:' "$@" echo "n=$n" } main -a "foo 1" -a '$((ls))' -u unused -n x -n last_n_val a1 a2