delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/12/29/14:38:08

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Mon, 29 Dec 2003 14:37:52 -0500 (EST)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: "Blair P. Houghton" <blair AT houghton DOT net>
cc: cygwin AT cygwin DOT com
Subject: RE: Question about ash and getopts
In-Reply-To: <DLEDLBGGCHGDFMMGKBHBAELBCDAA.blair@houghton.net>
Message-ID: <Pine.GSO.4.56.0312291434200.18706@slinky.cs.nyu.edu>
References: <DLEDLBGGCHGDFMMGKBHBAELBCDAA DOT blair AT houghton DOT net>
MIME-Version: 1.0

On Mon, 29 Dec 2003, Blair P. Houghton wrote:

> Peter Seebach wrote:
> >In message <3FEFDE5B DOT 3000801 AT helixdigital DOT com>, Dario Alcocer writes:
> >>Use the "set -- `getopt`" idiom instead:
> >Yes, but *why*?
>
> ==============
> % cygcheck --version
> cygcheck version 1.30
> System Checker for Cygwin
> Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
> Compiled on Feb  8 2003

FYI, this doesn't tell us anything about the version of Cygwin or the
associated utilities.  'uname -a' does slightly better.  For the full set
of information you can report about your system, see
<http://cygwin.com/problems.html>.

> % cat > bt.sh
> #!/bin/sh
>
> set -- `getopt`
>
> echo $0 $2 $4
> echo $1 $3 $5
> ^D
> % bt.sh 1 2 3 4 5 6
> getopt: missing optstring argument
> Try `getopt --help' for more information.
> ./bt.sh
> ===============
>
> Hey.  It got $0 right.
>
> So I take it this "idiom" is only supposed to work in newer cygwin versions?

Try "getopt --help".  In a shell that does have 'getopts', you wouldn't
use the no-arg form, so why expect it to work here?  'set -- `getopt`' was
called an *idiom*, not the exact command to use.  You give 'getopt' the
same parameters you'd give to 'getopts' in bash.

> And I too am puzzled why someone would defeature a shell instead of
> letting it work with either method.  I don't see it as a portability
> issue unless you think a significant number of users will be porting
> their scripts from systems running cygwin to systems running atavistic
> variants of UNIX.
>
> --Blair

I'm sure this discussion is in the archives somewhere.
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton

--
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/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019