This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[pdksh]getopts problem in conjunction with shift


Hi,

    I have the following script (a.ksh) :

$ cat a.ksh
#!/usr/bin/ksh -x

echo $*
getopts abc var

echo $?
echo $var
echo $OPTIND
echo $OPTARG

shift

echo $*
getopts abc var

echo $?
echo $var
echo $OPTIND
echo $OPTARG

    When run on AIX ksh, it produces the following (expected output) :

$ ./a.ksh -a something
+ echo -a something
-a something
+ getopts abc var
+ echo 0
0
+ echo a
a
+ echo 2
2
+ echo

+ shift
+ echo something
something
+ getopts abc var
+ echo 1
1
+ echo ?
?
+ echo 2
2
+ echo

    On Cygwin (pdksh 5.2.14-3), it produces :

bash-2.05b$ ./a.ksh -a something
+ echo -a something
-a something
+ getopts abc var
+ echo 0
0
+ echo a
a
+ echo 2
2
+ echo

+ shift
+ echo something
something
+ getopts abc var
./a.ksh[14]: -m: unknown option
+ echo 0
0
+ echo ?
?
+ echo 2
2
+ echo

    Why is it dying like this?

Thanks,
Kenneth

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]