On Wed, 28 Nov 2012 12:14:16 +0800 Clark WANG wrote: > --===============8121031177745599784== > Content-Type: multipart/alternative; boundary=e89a8f5032ccc9ffde04cf86685a
> --e89a8f5032ccc9ffde04cf86685a > Content-Type: text/plain; charset=UTF-8 > 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: thanks for responding Clark this is expected behavior > [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 > > > --e89a8f5032ccc9ffde04cf86685a > Content-Type: text/html; charset=UTF-8 > Content-Transfer-Encoding: quoted-printable > <font><font face=3D"arial,helvetica,sans-serif"></font></font>On Tue, Nov 2= > 7, 2012 at 2:28 PM, Aaron Davies <span dir=3D"ltr"><<a href=3D"mailto:aa= > [email protected]" target=3D"_blank">[email protected]</a>></spa= > n> wrote:<br> > <div class=3D"gmail_quote"><blockquote class=3D"gmail_quote" style=3D"margi= > n:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">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 avail= > able global flags for that mode.<br> > </blockquote><div><br>If I understand you correctly following is what you e= > xpected:<br><br><span style=3D"font-family:courier new,monospace">[STEP 101= > ] $ cat foo.ksh<br>#!/usr/bin/ksh<br><br>function f3<br>{<br>=C2=A0=C2=A0= > =C2=A0 typeset opt<br> > <br>=C2=A0=C2=A0=C2=A0 getopts '[-][f:file]:[FILE][h:help]' opt<br>= > =C2=A0=C2=A0=C2=A0 echo "opt=3D$opt OPTARG=3D$OPTARG"<br>}<br><br= > >function f4<br>{<br>=C2=A0=C2=A0=C2=A0 typeset opt<br><br>=C2=A0=C2=A0=C2= > =A0 getopts ':[-][f:file]:[FILE][h:help]' opt<br>=C2=A0=C2=A0=C2=A0= > echo "opt=3D$opt OPTARG=3D$OPTARG"<br> > }<br><br>echo =3D=3D=3D=3D f3 =3D=3D=3D=3D<br>f3 -x<br>f3 --file file1<br>f= > 3 --file<br><br>echo =3D=3D=3D=3D f4 =3D=3D=3D=3D<br>f4 -y<br>f4 --file fil= > e2<br>f4 --file<br>[STEP 102] $ ksh foo.ksh<br>=3D=3D=3D=3D f3 =3D=3D=3D=3D= > <br>foo.ksh[20]: f3: -x: unknown option<br> > opt=3D? OPTARG=3D<br> > opt=3Df OPTARG=3Dfile1<br>foo.ksh[22]: f3: --file: FILE value expected<br>o= > pt=3D? OPTARG=3D<br>=3D=3D=3D=3D f4 =3D=3D=3D=3D<br>opt=3D? OPTARG=3Dy<br>o= > pt=3Df OPTARG=3Dfile2<br>opt=3D: OPTARG=3Df<br>[STEP 103] $</span><br>=C2= > =A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0 0 0 .8ex;borde= > r-left:1px #ccc solid;padding-left:1ex"> > <span class=3D"HOEnZb"><font color=3D"#888888">--<br> > Aaron Davies<br> > <a href=3D"mailto:[email protected]">[email protected]</a><br> > _______________________________________________<br> > ast-users mailing list<br> > <a href=3D"mailto:[email protected]">[email protected]= > h.att.com</a><br> > <a href=3D"http://lists.research.att.com/mailman/listinfo/ast-users" target= > =3D"_blank">http://lists.research.att.com/mailman/listinfo/ast-users</a><br= > > > </font></span></blockquote></div><br> > --e89a8f5032ccc9ffde04cf86685a-- > --===============8121031177745599784== > Content-Type: text/plain; charset="us-ascii" > MIME-Version: 1.0 > Content-Transfer-Encoding: 7bit > Content-Disposition: inline > _______________________________________________ > ast-users mailing list > [email protected] > http://lists.research.att.com/mailman/listinfo/ast-users > --===============8121031177745599784==-- _______________________________________________ ast-users mailing list [email protected] http://lists.research.att.com/mailman/listinfo/ast-users
