From owner-freebsd-questions Fri Aug 17 11:23:52 2001 Delivered-To: freebsd-questions@freebsd.org Received: from comp04.prc.uic.edu (comp04.prc.uic.edu [128.248.230.104]) by hub.freebsd.org (Postfix) with SMTP id A652537B40C for ; Fri, 17 Aug 2001 11:23:49 -0700 (PDT) (envelope-from lucas@comp04.prc.uic.edu) Received: (qmail 79274 invoked by uid 1000); 17 Aug 2001 18:24:11 -0000 Date: Fri, 17 Aug 2001 13:24:11 -0500 From: Lucas Bergman To: parv Cc: questions@freebsd.org Subject: Re: long options in shell script Message-ID: <20010817132411.D75148@comp04.prc.uic.edu> Reply-To: lucas@slb.to References: <20010817015201.A26996@moo.holy.cow> <20010817011800.P4232@blossom.cjclark.org> <20010817043458.A28979@moo.holy.cow> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i In-Reply-To: <20010817043458.A28979@moo.holy.cow>; from parv_@yahoo.com on Fri, Aug 17, 2001 at 04:34:58AM -0400 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG > i got tired of making symlinks to a script and behaving depending on > basename. > > so i am searching for a way to implement long options (bourne > shell). does anybody have short example or where to find one? What does depending on basename have to do with long options? Anyway, may I first suggest that your script may be outgrowing sh. For example, Perl has 'use Getopt::Long' that does what you want. Failing that, if expr "$arg" : --; then # $arg begins with '--' fi will detect whether $arg begins with '--'. And, echo "$arg" | sed 's,^[^=]*=,,' will tell you what comes after the (first) '=' sign in $arg. Lucas To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message