3 ms·
It is the (social contract) responsibility of the programmer to document in the usage and in the manual page that -u takes a username as an argument, and where
by Annatar 10y ago
It is the (social contract) responsibility of the programmer to document in the usage and in the manual page that -u takes a username as an argument, and where such documentation exists, the convention is that username may be provided as -uuser or -u user.
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.