SUMMARY: Problems with Bourne Shell and getopts

From: Richard Sharpe <sharpe_at_ns.aus.com>
Date: Sun, 10 Jan 1999 12:09:28 +1000

Don't know whether or not this justifies a summary, but here goes.

I asked:

> I have seen reports that suggest that the Bourne shell under Digital UNIX
> has problems with $OPTIND when using getopt.
>
> When I last looked, there seemed to be a problem if there are no command
> line parameters to a shell, $OPTIND seems undefined.
>
> However, reports I have seen suggest that $OPTIND may be undefined in all
> cases.

Thanks to Tom Blinn and Charles Richmond, and some experimentation, I found
that indeed, getopts is not well supported in sh under DU.

Tom pointed out that under DU 4.0 and later, sh has two versions. One (the
better one) is POSIX/XPG4 compatible and supports what I want. The older
one does not.

ksh supports everything I need. Now to see how to rectify the problem.

Under DU, ksh seems to be /usr/bin/posix/sh, which is the POSIX/XPG4 sh.



Regards
-------
Richard Sharpe, sharpe_at_ns.aus.com, NIC-Handle:RJS96
NS Computer Software and Services P/L,
Ph: +61-8-8281-0063, FAX: +61-8-8250-2080,
Samba, Linux, Apache, Digital UNIX, AIX, Netscape, Stronghold, C, ...
Received on Sun Jan 10 1999 - 00:45:09 NZDT

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:38 NZDT