Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 17 Aug 2001 13:24:11 -0500
From:      Lucas Bergman <lucas@slb.to>
To:        parv <parv_@yahoo.com>
Cc:        questions@freebsd.org
Subject:   Re: long options in shell script
Message-ID:  <20010817132411.D75148@comp04.prc.uic.edu>
In-Reply-To: <20010817043458.A28979@moo.holy.cow>; from parv_@yahoo.com on Fri, Aug 17, 2001 at 04:34:58AM -0400
References:  <20010817015201.A26996@moo.holy.cow> <20010817011800.P4232@blossom.cjclark.org> <20010817043458.A28979@moo.holy.cow>

next in thread | previous in thread | raw e-mail | index | archive | help
> 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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20010817132411.D75148>