On Tue, Nov 27, 2012 at 2:28 PM, Aaron Davies <[email protected]>wrote:
> is it possible to get the "leading-colon" error-handling behavior of
> getopts when using the extended interface? colon doesn't seem to be one of
> the available global flags for that mode.
>
If I understand you correctly following is what you expected:
[STEP 101] $ cat foo.ksh
#!/usr/bin/ksh
function f3
{
typeset opt
getopts '[-][f:file]:[FILE][h:help]' opt
echo "opt=$opt OPTARG=$OPTARG"
}
function f4
{
typeset opt
getopts ':[-][f:file]:[FILE][h:help]' opt
echo "opt=$opt OPTARG=$OPTARG"
}
echo ==== f3 ====
f3 -x
f3 --file file1
f3 --file
echo ==== f4 ====
f4 -y
f4 --file file2
f4 --file
[STEP 102] $ ksh foo.ksh
==== f3 ====
foo.ksh[20]: f3: -x: unknown option
opt=? OPTARG=
opt=f OPTARG=file1
foo.ksh[22]: f3: --file: FILE value expected
opt=? OPTARG=
==== f4 ====
opt=? OPTARG=y
opt=f OPTARG=file2
opt=: OPTARG=f
[STEP 103] $
> --
> Aaron Davies
> [email protected]
> _______________________________________________
> ast-users mailing list
> [email protected]
> http://lists.research.att.com/mailman/listinfo/ast-users
>
_______________________________________________
ast-users mailing list
[email protected]
http://lists.research.att.com/mailman/listinfo/ast-users