Initial import of gnugetopt-1.1.4.
GNU getopt(1) is a program to help shell scripts parse command-line parameters. Port started by msf@ and finished by me. ok msf@
This commit is contained in:
parent
8ab7f50373
commit
6a5d8b9dd3
36
misc/gnugetopt/Makefile
Normal file
36
misc/gnugetopt/Makefile
Normal file
@ -0,0 +1,36 @@
|
||||
# $OpenBSD: Makefile,v 1.1.1.1 2006/11/03 13:25:02 bernd Exp $
|
||||
|
||||
COMMENT= "GNU getopt(1) utility"
|
||||
|
||||
DISTNAME= getopt-1.1.4
|
||||
PKGNAME= ${DISTNAME:S/getopt/gnugetopt/}
|
||||
CATEGORIES= misc
|
||||
|
||||
# GPL
|
||||
PERMIT_PACKAGE_CDROM= Yes
|
||||
PERMIT_PACKAGE_FTP= Yes
|
||||
PERMIT_DISTFILES_CDROM= Yes
|
||||
PERMIT_DISTFILES_FTP= Yes
|
||||
|
||||
MASTER_SITES= http://software.frodo.looijaard.name/getopt/files/
|
||||
|
||||
WANTLIB= c
|
||||
|
||||
MODULES= devel/gettext
|
||||
|
||||
USE_GMAKE= Yes
|
||||
MAKE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \
|
||||
LDFLAGS="-L${LOCALBASE}/lib -lintl -liconv"
|
||||
|
||||
NO_REGRESS= Yes
|
||||
|
||||
do-install:
|
||||
cd ${WRKSRC} && sed -e 's,/usr/local,${LOCALBASE},g' \
|
||||
< ${WRKSRC}/getopt.1 > ${WRKSRC}/getopt.1.fixed
|
||||
${INSTALL_PROGRAM} ${WRKBUILD}/getopt ${PREFIX}/bin/gnugetopt
|
||||
${INSTALL_MAN} ${WRKBUILD}/getopt.1.fixed ${PREFIX}/man/man1/gnugetopt.1
|
||||
${INSTALL_DATA_DIR} ${PREFIX}/share/examples/gnugetopt
|
||||
${INSTALL_DATA} ${WRKBUILD}/getopt-parse.* \
|
||||
${PREFIX}/share/examples/gnugetopt
|
||||
|
||||
.include <bsd.port.mk>
|
4
misc/gnugetopt/distinfo
Normal file
4
misc/gnugetopt/distinfo
Normal file
@ -0,0 +1,4 @@
|
||||
MD5 (getopt-1.1.4.tar.gz) = 02188ca68da27c4175d6e9f3da732101
|
||||
RMD160 (getopt-1.1.4.tar.gz) = 79fffccf1b48956bfc1fbb19c22c2d94adf10dff
|
||||
SHA1 (getopt-1.1.4.tar.gz) = 8b9b329b3a8f5d52c91c0381616ecbd1ba291486
|
||||
SIZE (getopt-1.1.4.tar.gz) = 37163
|
42
misc/gnugetopt/patches/patch-Makefile
Normal file
42
misc/gnugetopt/patches/patch-Makefile
Normal file
@ -0,0 +1,42 @@
|
||||
$OpenBSD: patch-Makefile,v 1.1.1.1 2006/11/03 13:25:02 bernd Exp $
|
||||
--- Makefile.orig Mon Nov 7 23:32:46 2005
|
||||
+++ Makefile Thu Nov 2 15:07:47 2006
|
||||
@@ -1,17 +1,17 @@
|
||||
.SUFFIXES:
|
||||
|
||||
DESTDIR=
|
||||
-prefix=/usr/local
|
||||
+prefix=$(PREFIX)
|
||||
bindir=$(prefix)/bin
|
||||
mandir=$(prefix)/man
|
||||
man1dir=$(mandir)/man1
|
||||
libdir=$(prefix)/lib
|
||||
sharedir=$(prefix)/share
|
||||
-getoptdir=$(libdir)/getopt
|
||||
+getoptdir=$(sharedir)/examples/getopt
|
||||
localedir=$(sharedir)/locale
|
||||
|
||||
# Define this to 0 to use the getopt(3) routines in this package.
|
||||
-LIBCGETOPT=1
|
||||
+LIBCGETOPT=0
|
||||
|
||||
# Define this to 1 if you do not have the gettext routines
|
||||
WITHOUT_GETTEXT=0
|
||||
@@ -33,7 +33,7 @@ MSGFMT=msgfmt
|
||||
LANGUAGES = cs de es fr it ja nl pt_BR
|
||||
MOFILES:=$(patsubst %,po/%.mo,$(LANGUAGES))
|
||||
|
||||
-CPPFLAGS=-DLIBCGETOPT=$(LIBCGETOPT) -DWITH_GETTEXT=$(WITH_GETTEXT) -DLOCALEDIR=\"$(localedir)\" -DNOT_UTIL_LINUX
|
||||
+CPPFLAGS+=-DLIBCGETOPT=$(LIBCGETOPT) -DWITH_GETTEXT=$(WITH_GETTEXT) -DLOCALEDIR=\"$(localedir)\" -DNOT_UTIL_LINUX
|
||||
ifeq ($(LIBCGETOPT),0)
|
||||
CPPFLAGS+=-I./gnu
|
||||
endif
|
||||
@@ -43,8 +43,6 @@ WARNINGS=-Wall \
|
||||
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
|
||||
-Wnested-externs -Winline
|
||||
OPTIMIZE=-O3 -fno-strength-reduce
|
||||
-CFLAGS=$(WARNINGS) $(OPTIMIZE)
|
||||
-LDFLAGS=
|
||||
|
||||
sources=getopt.c
|
||||
ifeq ($(LIBCGETOPT),0)
|
22
misc/gnugetopt/patches/patch-getopt-parse_bash
Normal file
22
misc/gnugetopt/patches/patch-getopt-parse_bash
Normal file
@ -0,0 +1,22 @@
|
||||
$OpenBSD: patch-getopt-parse_bash,v 1.1.1.1 2006/11/03 13:25:02 bernd Exp $
|
||||
--- getopt-parse.bash.orig Thu Nov 2 15:33:00 2006
|
||||
+++ getopt-parse.bash Thu Nov 2 15:33:49 2006
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
-# A small example program for using the new getopt(1) program.
|
||||
+# A small example program for using the new gnugetopt(1) program.
|
||||
# This program will only work with bash(1)
|
||||
# An similar program using the tcsh(1) script language can be found
|
||||
# as parse.tcsh
|
||||
@@ -18,8 +18,8 @@
|
||||
|
||||
# Note that we use `"$@"' to let each command-line parameter expand to a
|
||||
# separate word. The quotes around `$@' are essential!
|
||||
-# We need TEMP as the `eval set --' would nuke the return value of getopt.
|
||||
-TEMP=`getopt -o ab:c:: --long a-long,b-long:,c-long:: \
|
||||
+# We need TEMP as the `eval set --' would nuke the return value of gnugetopt.
|
||||
+TEMP=`gnugetopt -o ab:c:: --long a-long,b-long:,c-long:: \
|
||||
-n 'example.bash' -- "$@"`
|
||||
|
||||
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
32
misc/gnugetopt/patches/patch-getopt-parse_tcsh
Normal file
32
misc/gnugetopt/patches/patch-getopt-parse_tcsh
Normal file
@ -0,0 +1,32 @@
|
||||
$OpenBSD: patch-getopt-parse_tcsh,v 1.1.1.1 2006/11/03 13:25:02 bernd Exp $
|
||||
--- getopt-parse.tcsh.orig Thu Nov 2 15:33:06 2006
|
||||
+++ getopt-parse.tcsh Thu Nov 2 15:33:32 2006
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/tcsh
|
||||
|
||||
-# A small example program for using the new getopt(1) program.
|
||||
+# A small example program for using the new gnugetopt(1) program.
|
||||
# This program will only work with tcsh(1)
|
||||
# An similar program using the bash(1) script language can be found
|
||||
# as parse.bash
|
||||
@@ -17,16 +17,16 @@
|
||||
# --> `wow!*\?'
|
||||
|
||||
# Note that we had to escape the exclamation mark in the wow-argument. This
|
||||
-# is _not_ a problem with getopt, but with the tcsh command parsing. If you
|
||||
+# is _not_ a problem with gnugetopt, but with the tcsh command parsing. If you
|
||||
# would give the same line from the bash prompt (ie. call ./parse.tcsh),
|
||||
# you could remove the exclamation mark.
|
||||
|
||||
# This is a bit tricky. We use a temp variable, to be able to check the
|
||||
-# return value of getopt (eval nukes it). argv contains the command arguments
|
||||
+# return value of gnugetopt (eval nukes it). argv contains the command arguments
|
||||
# as a list. The ':q` copies that list without doing any substitutions:
|
||||
-# each element of argv becomes a separate argument for getopt. The braces
|
||||
+# each element of argv becomes a separate argument for gnugetopt. The braces
|
||||
# are needed because the result is also a list.
|
||||
-set temp=(`getopt -s tcsh -o ab:c:: --long a-long,b-long:,c-long:: -- $argv:q`)
|
||||
+set temp=(`gnugetopt -s tcsh -o ab:c:: --long a-long,b-long:,c-long:: -- $argv:q`)
|
||||
if ($? != 0) then
|
||||
echo "Terminating..." >/dev/stderr
|
||||
exit 1
|
199
misc/gnugetopt/patches/patch-getopt_1
Normal file
199
misc/gnugetopt/patches/patch-getopt_1
Normal file
@ -0,0 +1,199 @@
|
||||
$OpenBSD: patch-getopt_1,v 1.1.1.1 2006/11/03 13:25:02 bernd Exp $
|
||||
--- getopt.1.orig Mon Nov 7 23:16:38 2005
|
||||
+++ getopt.1 Thu Nov 2 15:21:45 2006
|
||||
@@ -1,14 +1,14 @@
|
||||
-.TH GETOPT 1 "May 31, 1997" Linux ""
|
||||
+.TH GNUGETOPT 1 "May 31, 1997" Linux ""
|
||||
.SH NAME
|
||||
-getopt \- parse command options (enhanced)
|
||||
+gnugetopt \- parse command options (enhanced)
|
||||
.SH SYNOPSIS
|
||||
-.BR getopt " optstring parameters"
|
||||
+.BR gnugetopt " optstring parameters"
|
||||
|
||||
-.BR getopt " [options] [" \-\- "] optstring parameters"
|
||||
+.BR gnugetopt " [options] [" \-\- "] optstring parameters"
|
||||
|
||||
-.BR getopt " [options] " \-o | \-\-options " optstring [options] [" \-\- "] parameters"
|
||||
+.BR gnugetopt " [options] " \-o | \-\-options " optstring [options] [" \-\- "] parameters"
|
||||
.SH DESCRIPTION
|
||||
-.B getopt
|
||||
+.B gnugetopt
|
||||
is used to break up
|
||||
.RI ( parse )
|
||||
options in command lines for easy parsing by
|
||||
@@ -19,9 +19,9 @@ It uses the
|
||||
routines to do this.
|
||||
|
||||
The parameters
|
||||
-.B getopt
|
||||
+.B gnugetopt
|
||||
is called with can be divided into two parts: options
|
||||
-which modify the way getopt will parse
|
||||
+which modify the way gnugetopt will parse
|
||||
.RI ( options
|
||||
and
|
||||
.I \-o|\-\-options optstring
|
||||
@@ -49,7 +49,7 @@ is not an option (does not start with a
|
||||
.RB ` \- ',
|
||||
this is the first format in the
|
||||
.BR SYNOPSIS),
|
||||
-.B getopt
|
||||
+.B gnugetopt
|
||||
will generate output that is compatible with that of other versions of
|
||||
.BR getopt (1).
|
||||
It will still do parameter shuffling and recognize optional
|
||||
@@ -67,12 +67,12 @@ by using the
|
||||
.B eval
|
||||
command). This has the effect of preserving those characters, but
|
||||
you must call
|
||||
-.B getopt
|
||||
+.B gnugetopt
|
||||
in a way that is no longer compatible with other versions (the second
|
||||
or third format in the
|
||||
.BR SYNOPSIS).
|
||||
To determine whether this enhanced version of
|
||||
-.BR getopt (1)
|
||||
+.BR gnugetopt (1)
|
||||
is installed, a special test option
|
||||
.RB ( \-T )
|
||||
can be used.
|
||||
@@ -95,14 +95,14 @@ in
|
||||
may be followed by one colon to indicate it has a required argument,and by two colons to indicate it has an optional argument.
|
||||
.IP "\-n, \-\-name progname"
|
||||
The name that will be used by the
|
||||
-.BR getopt (3)
|
||||
+.BR gnugetopt (3)
|
||||
routines when it reports errors. Note that errors of
|
||||
-.BR getopt (1)
|
||||
-are still reported as coming from getopt.
|
||||
+.BR gnugetopt (1)
|
||||
+are still reported as coming from gnugetopt.
|
||||
.IP "\-o, \-\-options shortopts"
|
||||
The short (one\-character) options to be recognized. If this option is not
|
||||
found, the first parameter of
|
||||
-.B getopt
|
||||
+.B gnugetopt
|
||||
that does not start with
|
||||
a
|
||||
.RB ` \- '
|
||||
@@ -121,10 +121,10 @@ options are parsed and output is generat
|
||||
.B SCANNING MODES
|
||||
for details).
|
||||
.IP "\-q, \-\-quiet"
|
||||
-Disable error reporting by getopt(3).
|
||||
+Disable error reporting by gnugetopt(3).
|
||||
.IP "\-Q, \-\-quiet\-output"
|
||||
Do not generate normal output. Errors are still reported by
|
||||
-.BR getopt (3),
|
||||
+.BR gnugetopt (3),
|
||||
unless you also use
|
||||
.IR \-q .
|
||||
.IP "\-s, \-\-shell shell"
|
||||
@@ -144,7 +144,7 @@ characters can cause havoc in this mode
|
||||
implementations).
|
||||
.IP "\-T \-\-test"
|
||||
Test if your
|
||||
-.BR getopt (1)
|
||||
+.BR gnugetopt (1)
|
||||
is this enhanced version or an old version. This generates no output,
|
||||
and sets the error status to 4. Other implementations of
|
||||
.BR getopt (1),
|
||||
@@ -158,7 +158,7 @@ and error status 0.
|
||||
Output version information and exit succesfully. No other output is generated.
|
||||
.SH PARSING
|
||||
This section specifies the format of the second part of the parameters of
|
||||
-.B getopt
|
||||
+.B gnugetopt
|
||||
(the
|
||||
.I parameters
|
||||
in the
|
||||
@@ -170,7 +170,7 @@ generated. These parameters were typical
|
||||
was called with.
|
||||
Care must be taken that each parameter the shell function was
|
||||
called with corresponds to exactly one parameter in the parameter list of
|
||||
-.B getopt
|
||||
+.B gnugetopt
|
||||
(see the
|
||||
.BR EXAMPLES ).
|
||||
All parsing is done by the GNU
|
||||
@@ -355,14 +355,14 @@ parameter is still generated, but it wil
|
||||
this mode.
|
||||
.SH COMPATIBILITY
|
||||
This version of
|
||||
-.BR getopt (1)
|
||||
+.BR gnugetopt (1)
|
||||
is written to be as compatible as possible to
|
||||
other versions. Usually you can just replace them with this version
|
||||
without any modifications, and with some advantages.
|
||||
|
||||
-If the first character of the first parameter of getopt is not a
|
||||
+If the first character of the first parameter of gnugetopt is not a
|
||||
.RB ` \- ',
|
||||
-getopt goes into compatibility mode. It will interpret its first parameter as
|
||||
+gnugetopt goes into compatibility mode. It will interpret its first parameter as
|
||||
the string of short options, and all other arguments will be parsed. It
|
||||
will still do parameter shuffling (ie. all non\-option parameters are outputed
|
||||
at the end), unless the environment variable
|
||||
@@ -372,7 +372,7 @@ is set.
|
||||
The environment variable
|
||||
.B GETOPT_COMPATIBLE
|
||||
forces
|
||||
-.B getopt
|
||||
+.B gnugetopt
|
||||
into compatibility mode. Setting both this environment variable and
|
||||
.B POSIXLY_CORRECT
|
||||
offers 100% compatibility for `difficult' programs. Usually, though,
|
||||
@@ -384,13 +384,13 @@ and
|
||||
.RB ` + '
|
||||
characters in the short options string are ignored.
|
||||
.SH RETURN CODES
|
||||
-.B getopt
|
||||
+.B gnugetopt
|
||||
returns error code
|
||||
.B 0
|
||||
for succesful parsing,
|
||||
.B 1
|
||||
if
|
||||
-.BR getopt (3)
|
||||
+.BR gnugetopt (3)
|
||||
returns errors,
|
||||
.B 2
|
||||
if it does not understand its own parameters,
|
||||
@@ -401,15 +401,13 @@ if it is called with
|
||||
.BR \-T .
|
||||
.SH EXAMPLES
|
||||
Example scripts for (ba)sh and (t)csh are provided with the
|
||||
-.BR getopt (1)
|
||||
+.BR gnugetopt (1)
|
||||
distribution, and are optionally installed in
|
||||
-.B /usr/local/lib/getopt
|
||||
-or
|
||||
-.BR /usr/lib/getopt .
|
||||
+.B /usr/local/share/examples/gnugetopt .
|
||||
.SH ENVIRONMENT
|
||||
.IP POSIXLY_CORRECT
|
||||
This environment variable is examined by the
|
||||
-.BR getopt (3)
|
||||
+.BR gnugetopt (3)
|
||||
routines.
|
||||
If it is set, parsing stops as soon as a parameter
|
||||
is found that is not an option or an option argument. All remaining
|
||||
@@ -418,14 +416,14 @@ whether they start with a
|
||||
.RB ` \- '.
|
||||
.IP GETOPT_COMPATIBLE
|
||||
Forces
|
||||
-.B getopt
|
||||
+.B gnugetopt
|
||||
to use the first calling format as specified in the
|
||||
.BR SYNOPSIS .
|
||||
.SH BUGS
|
||||
-.BR getopt (3)
|
||||
+.BR gnugetopt (3)
|
||||
can parse long options with optional arguments that are given an empty optional
|
||||
argument (but can not do this for short options). This
|
||||
-.BR getopt (1)
|
||||
+.BR gnugetopt (1)
|
||||
treats optional arguments that are empty as if they were not present.
|
||||
|
||||
The syntax if you do not want any short option variables at all is
|
63
misc/gnugetopt/patches/patch-getopt_c
Normal file
63
misc/gnugetopt/patches/patch-getopt_c
Normal file
@ -0,0 +1,63 @@
|
||||
$OpenBSD: patch-getopt_c,v 1.1.1.1 2006/11/03 13:25:02 bernd Exp $
|
||||
--- getopt.c.orig Mon Nov 7 23:17:01 2005
|
||||
+++ getopt.c Fri Nov 3 14:18:16 2006
|
||||
@@ -88,7 +88,7 @@ void *our_malloc(size_t size)
|
||||
{
|
||||
void *ret=malloc(size);
|
||||
if (! ret) {
|
||||
- fprintf(stderr,_("%s: Out of memory!\n"),"getopt");
|
||||
+ fprintf(stderr,_("%s: Out of memory!\n"),"gnugetopt");
|
||||
exit(3);
|
||||
}
|
||||
return(ret);
|
||||
@@ -98,7 +98,7 @@ void *our_realloc(void *ptr, size_t size
|
||||
{
|
||||
void *ret=realloc(ptr,size);
|
||||
if (! ret && size) {
|
||||
- fprintf(stderr,_("%s: Out of memory!\n"),"getopt");
|
||||
+ fprintf(stderr,_("%s: Out of memory!\n"),"gnugetopt");
|
||||
exit(3);
|
||||
}
|
||||
return(ret);
|
||||
@@ -231,8 +231,8 @@ int generate_output(char * argv[],int ar
|
||||
void parse_error(const char *message)
|
||||
{
|
||||
if (message)
|
||||
- fprintf(stderr,"getopt: %s\n",message);
|
||||
- fputs(_("Try `getopt --help' for more information.\n"),stderr);
|
||||
+ fprintf(stderr,"gnugetopt: %s\n",message);
|
||||
+ fputs(_("Try `gnugetopt --help' for more information.\n"),stderr);
|
||||
exit(2);
|
||||
}
|
||||
|
||||
@@ -323,9 +323,9 @@ void set_shell(const char *new_shell)
|
||||
|
||||
void print_help(void)
|
||||
{
|
||||
- fputs(_("Usage: getopt optstring parameters\n"),stderr);
|
||||
- fputs(_(" getopt [options] [--] optstring parameters\n"),stderr);
|
||||
- fputs(_(" getopt [options] -o|--options optstring [options] [--]\n"),stderr);
|
||||
+ fputs(_("Usage: gnugetopt optstring parameters\n"),stderr);
|
||||
+ fputs(_(" gnugetopt [options] [--] optstring parameters\n"),stderr);
|
||||
+ fputs(_(" gnugetopt [options] -o|--options optstring [options] [--]\n"),stderr);
|
||||
fputs(_(" parameters\n"),stderr);
|
||||
fputs(_(" -a, --alternative Allow long options starting with single -\n"),stderr);
|
||||
fputs(_(" -h, --help This small usage guide\n"),stderr);
|
||||
@@ -335,7 +335,7 @@ void print_help(void)
|
||||
fputs(_(" -q, --quiet Disable error reporting by getopt(3)\n"),stderr);
|
||||
fputs(_(" -Q, --quiet-output No normal output\n"),stderr);
|
||||
fputs(_(" -s, --shell=shell Set shell quoting conventions\n"),stderr);
|
||||
- fputs(_(" -T, --test Test for getopt(1) version\n"),stderr);
|
||||
+ fputs(_(" -T, --test Test for gnugetopt(1) version\n"),stderr);
|
||||
fputs(_(" -u, --unqote Do not quote the output\n"),stderr);
|
||||
fputs(_(" -V, --version Output version information\n"),stderr);
|
||||
exit(2);
|
||||
@@ -443,7 +443,7 @@ int main(int argc, char *argv[])
|
||||
quote=0;
|
||||
break;
|
||||
case 'V':
|
||||
- printf(_("getopt (enhanced) 1.1.4\n"));
|
||||
+ printf(_("gnugetopt (enhanced) 1.1.4\n"));
|
||||
exit(0);
|
||||
case '?':
|
||||
case ':':
|
1
misc/gnugetopt/pkg/DESCR
Normal file
1
misc/gnugetopt/pkg/DESCR
Normal file
@ -0,0 +1 @@
|
||||
GNU getopt(1) is a program to help shell scripts parse command-line parameters.
|
6
misc/gnugetopt/pkg/PLIST
Normal file
6
misc/gnugetopt/pkg/PLIST
Normal file
@ -0,0 +1,6 @@
|
||||
@comment $OpenBSD: PLIST,v 1.1.1.1 2006/11/03 13:25:02 bernd Exp $
|
||||
bin/gnugetopt
|
||||
@man man/man1/gnugetopt.1
|
||||
share/examples/gnugetopt/
|
||||
share/examples/gnugetopt/getopt-parse.bash
|
||||
share/examples/gnugetopt/getopt-parse.tcsh
|
Loading…
Reference in New Issue
Block a user