From owner-freebsd-questions Mon May 15 19: 7:43 2000 Delivered-To: freebsd-questions@freebsd.org Received: from cc942873-a.ewndsr1.nj.home.com (cc942873-a.ewndsr1.nj.home.com [24.2.89.207]) by hub.freebsd.org (Postfix) with ESMTP id 0745837B91C for ; Mon, 15 May 2000 19:07:40 -0700 (PDT) (envelope-from cjc@cc942873-a.ewndsr1.nj.home.com) Received: (from cjc@localhost) by cc942873-a.ewndsr1.nj.home.com (8.9.3/8.9.3) id WAA55570; Mon, 15 May 2000 22:04:33 -0400 (EDT) (envelope-from cjc) Date: Mon, 15 May 2000 22:04:33 -0400 From: "Crist J. Clark" To: Mark Ovens Cc: Erik Trulsson , questions@freebsd.org Subject: Re: getopt(1) or getopts(1)? Message-ID: <20000515220432.A55458@cc942873-a.ewndsr1.nj.home.com> Reply-To: cjclark@home.com References: <20000511231319.C1522@parish> <20000512084656.A1146@student.csd.uu.se> <20000512183403.A233@parish> <20000513013931.C39310@cc942873-a.ewndsr1.nj.home.com> <20000514110900.B232@parish> <20000514113604.A50543@cc942873-a.ewndsr1.nj.home.com> <20000515234055.C233@parish> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <20000515234055.C233@parish>; from mark@dogma.freebsd-uk.eu.org on Mon, May 15, 2000 at 11:40:56PM +0100 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Mon, May 15, 2000 at 11:40:56PM +0100, Mark Ovens wrote: > On Sun, May 14, 2000 at 11:36:04AM -0400, Crist J. Clark wrote: > > On Sun, May 14, 2000 at 11:09:00AM +0100, Mark Ovens wrote: > > > > > [snip] > > > > > > > I'd almost got there, except I didn't know that shift wasn't needed. > > > > > > > Almost makes life too easy, huh? > > > > > > Almost. It does seem somewhat lacking in the error handling dept. > > > though. Using the example code above, if you do: > > > > > > # foobar -o -a -b > > > > > > then getopts(1) thinks that ``-a'' is the argument to ``-o''. > > > > How do you know it is not? > > > > If ``-a'' is a valid argument to ``-o'' then it would require special > handling, not unlike filenames starting with ``-'', or containing > metacharacters, they need quoting. Is this standardized somewhere? And since when do filenames starting with '-' need special handling all of the time? A lot of common tools do not behave that way, $ echo -v | grep -e -v -v $ { echo \#!/bin/sh; echo echo YES; } > -a $ chmod 755 -a $ sh -c -a YES $ Including sh(1) itself. But of course... $ rm -a rm: illegal option -- a usage: rm [-f | -i] [-dPRrvW] file ... unlink file $ rm -- -a $ Lotsa times '-' files do. -- Crist J. Clark cjclark@home.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message