cc: [email protected]
Subject: Re: [ast-users] Telling getopts that an option's argument is required
--------
> In the following script, "vas", I want getopts to consider the
> arguments that might accompany options "u" and "s" to be "required"
> arguments. However, it doesn't.
>
> #! /bin/ksh
> USAGE="[+NAME?${0##*/}]
> [+DESCRIPTION?Lookup a user.]
> [u:username?The user's username.]:[user]
> [s:surname?The user's last name.]:[last]"
>
> while getopts "$USAGE" opt
> do
> case $opt in
> u) un="$OPTARG" ;;
> s) sn="$OPTARG" ;;
> \?) print -u2 "The \"?\" case. OPTARG: \"$OPTARG\"."; exit -1 ;;
> :) print -u2 "The \":\" case. OPTARG: \"$OPTARG\"."; exit -1 ;;
> esac
> done
>
Change the lines
[u:username?The user's username.]:[user]
[s:surname?The user's last name.]:[last]"
to
[u:username]:[user?The user's username.]
[s:surname]:[last?The user's last name.]"
This should allow -u or --username which takes a required option.
David Korn
[email protected]
_______________________________________________
ast-users mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-users