getopts problem

Chris Faylor cgf@cygnus.com
Wed Nov 10 13:02:00 GMT 1999


On Wed, Nov 10, 1999 at 02:35:36AM -0500, Glenn Spell wrote:
>On 9 Nov 1999 around 9:04AM (-0500) Christopher Faylor wrote:
>
>> On Tue, Nov 09, 1999 at 01:44:00PM +0000, Clive Bostock wrote:
>>
>> >However I now find that unless the 1st line of the shell script
>> >has the #!path_to_bash/bash included, bash errors with "getopts
>> >not found".
>>
>> /bin/sh != /bin/bash
>>
>> That's why.
>
>Well, more precisely, the /bin/sh he's using does not contain a
>builtin getopts function like bash does.
>
>One solution is to change your SHELL environment variable.
>
>Another solution is:
>
>    < http://www.fay.nc.us/~glenn/cygwin/sh.exe.gz >

Of course most UNIX implementations of /bin/sh do not have a builtin
'getopts' implementation.

I'd like to request that you add some way of identifying your version of
ash so that it will be obvious what somebody's using.  Otherwise I foresee
confusion on the cygwin mailing list.

>Frankly, I believe /bin/sh should be the "system" shell for Cygwin,
>just as it is for FreeBSD and NetBSD. In fact, I only joined the
>developers list when Chris posted "Just say no to ash"... I intended
>to start hollering and screaming... but before I got my information
>together, he changed his mind.

Actually, I posted it as a question and asked for feedback, as I usually
do with these things.  I don't recall you providing any feedback but I
could be mistaken.

>When it comes to an open source posix compatible Bourne type shell, ash
>is as good as it gets.  (Anyone ever try running a miminally configed
>bash in posix mode calling it as "sh".  No thank you, at least...  not
>on Cygwin.)

Except that I don't believe that ash actually *is* Posix compatible and
it's not really that robust.  It is riddled with small buffers which are
easy to overrun, causing random errors.

I spent a lot of time on the Cygwin CD poring over a version of ash,
paring it down to the functionality of something like the shell found on
Digital UNIX or HPUX.  I also increased the size of every buffer I found
dramatically.  This is just a band-aid but the /bin/sh on the CD should
be better than B20.1, FWIW.  It's also a lot smaller.

However, what this means is that there is, for instance, no 'alias', no
keystroke editing, no built-in getopts, etc.

>I made this last August from the ash source in NetBSD current.  I
>have never gotten around to going back and adding the stuff that
>Chris got from the FreeBSD port... brace expansion and some signal
>handling stuff if I recall correctly.

Hopefully I didn't release an ash with brace expansion or improved
signal handling.  If they were in the sources, I ifdef'ed them.

>Somewhere I have a comparison of my ash with the one that Chris
>ported from FreeBSD and posted about in the developers list.
>
>Chris, is the /bin/sh on the CD the same as the one you had up in
>your ftp area? (Sorry, I haven't purchased the CD yet.)

Not exactly.  No.

cgf

--
Want to unsubscribe from this list?
Send a message to cygwin-unsubscribe@sourceware.cygnus.com



More information about the Cygwin mailing list