In that third case, I find it crazy logic and confusing UX to have values with no space. If I type mysql -uroot on the command line, that should be equivalent to mysql -u -r -o -o -t but it's not.
This behaviour is defined in POSIX, btw:
>If the SYNOPSIS of a standard utility shows an option with a mandatory option-argument (as with [-c option_argument] in the example), a conforming application shall use separate arguments for that option and its option-argument. However, a conforming implementation shall also permit applications to specify the option and option-argument in the same argument string without intervening <blank> characters.
I suppose I don't mind that syntax anymore now. Thanks for changing my mind :)
This is trivially achievable with getopts(1):
while getopts u: Option
do
case "$Option"
in
u)
User="$OPTARG"
;;
esac
done
The colon tells getopts(1) that the -u option expects an argument. This behavior is also mandated by the POSIX specification.