ports/53174: [NEW PORT] misc/getopt: A getopt(1) replacement that supports GNU-style long options
Sergei Kolobov
sergei at kolobov.com
Wed Jun 11 00:10:20 UTC 2003
>Number: 53174
>Category: ports
>Synopsis: [NEW PORT] misc/getopt: A getopt(1) replacement that supports GNU-style long options
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Tue Jun 10 17:10:09 PDT 2003
>Closed-Date:
>Last-Modified:
>Originator: Sergei Kolobov
>Release: FreeBSD 5.1-CURRENT i386
>Organization:
>Environment:
System: FreeBSD elf.chetwood.ru 5.1-CURRENT FreeBSD 5.1-CURRENT #0: Thu Jun 5 02:19:41 MSD
>Description:
Rewrite of getopt(1) with the following features:
* It can do anything that the GNU getopt(3) routines can do.
* It can cope with spaces and shell metacharacters within arguments.
* It can parse long parameters.
* It can shuffle parameters, so you can mix options and other parameters
on the command-line.
* It can be easily identified as an enhanced getopt(1) from within shell
scripts.
* It can report parse errors as coming from the shell script.
* It compiles cleanly with both libc-5 and glibc-2.
Author: Frodo Looijaard <frodol at dds.nl>
WWW: http://huizen.dds.nl/~frodol/getopt.html
This port is required for upcoming textproc/xmlto port (to be submitted separately)
which is, in turn, required for an update to devel/makeplus port.
Tested (compiles and run) on 4.8-STABLE and 5.1-CURRENT (i386).
>How-To-Repeat:
>Fix:
--- getopt.shar begins here ---
# This is a shell archive. Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file". Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
# getopt
# getopt/pkg-descr
# getopt/distinfo
# getopt/files
# getopt/files/patch-getopt.c
# getopt/files/patch-Makefile
# getopt/Makefile
# getopt/pkg-plist
#
echo c - getopt
mkdir -p getopt > /dev/null 2>&1
echo x - getopt/pkg-descr
sed 's/^X//' >getopt/pkg-descr << 'END-of-getopt/pkg-descr'
XRewrite of getopt(1) with the following features:
X
X* It can do anything that the GNU getopt(3) routines can do.
X* It can cope with spaces and shell metacharacters within arguments.
X* It can parse long parameters.
X* It can shuffle parameters, so you can mix options and other parameters
X on the command-line.
X* It can be easily identified as an enhanced getopt(1) from within shell
X scripts.
X* It can report parse errors as coming from the shell script.
X* It compiles cleanly with both libc-5 and glibc-2.
X
XAuthor: Frodo Looijaard <frodol at dds.nl>
XWWW: http://huizen.dds.nl/~frodol/getopt.html
END-of-getopt/pkg-descr
echo x - getopt/distinfo
sed 's/^X//' >getopt/distinfo << 'END-of-getopt/distinfo'
XMD5 (getopt-1.1.3.tar.gz) = 7b7637dcb0ac531f1af29f4d6b018e86
END-of-getopt/distinfo
echo c - getopt/files
mkdir -p getopt/files > /dev/null 2>&1
echo x - getopt/files/patch-getopt.c
sed 's/^X//' >getopt/files/patch-getopt.c << 'END-of-getopt/files/patch-getopt.c'
X--- getopt.c.orig Thu Jun 5 16:00:34 2003
X+++ getopt.c Thu Jun 5 16:02:34 2003
X@@ -66,7 +66,6 @@
X int quiet_errors=0; /* 0 is not quiet. */
X int quiet_output=0; /* 0 is not quiet. */
X int quote=1; /* 1 is do quote. */
X-int alternative=0; /* 0 is getopt_long, 1 is getopt_long_only */
X
X /* Function prototypes */
X void *our_malloc(size_t size);
X@@ -188,9 +187,7 @@
X opterr=0;
X optind=0; /* Reset getopt(3) */
X
X- while ((opt = (alternative?
X- getopt_long_only(argc,argv,optstr,longopts,&longindex):
X- getopt_long(argc,argv,optstr,longopts,&longindex)))
X+ while ((opt = getopt_long(argc,argv,optstr,longopts,&longindex))
X != EOF)
X if (opt == '?' || opt == ':' )
X exit_code = 1;
X@@ -325,7 +322,6 @@
X fputs(_(" getopt [options] [--] optstring parameters\n"),stderr);
X fputs(_(" getopt [options] -o|--options optstring [options] [--]\n"),stderr);
X fputs(_(" parameters\n"),stderr);
X- fputs(_(" -a, --alternative Allow long options starting with single -\n"),stderr);
X fputs(_(" -h, --help This small usage guide\n"),stderr);
X fputs(_(" -l, --longoptions=longopts Long options to be recognized\n"),stderr);
X fputs(_(" -n, --name=progname The name under which errors are reported\n"),stderr);
X@@ -355,14 +351,13 @@
X {"test",no_argument,NULL,'T'},
X {"unquoted",no_argument,NULL,'u'},
X {"help",no_argument,NULL,'h'},
X- {"alternative",no_argument,NULL,'a'},
X {"name",required_argument,NULL,'n'},
X {"version",no_argument,NULL,'V'},
X {NULL,0,NULL,0}
X };
X
X /* Stop scanning as soon as a non-option argument is found! */
X-static const char *shortopts="+ao:l:n:qQs:TuhV";
X+static const char *shortopts="+o:l:n:qQs:TuhV";
X
X int main(int argc, char *argv[])
X {
X@@ -405,9 +400,6 @@
X
X while ((opt=getopt_long(argc,argv,shortopts,longopts,NULL)) != EOF)
X switch (opt) {
X- case 'a':
X- alternative=1;
X- break;
X case 'h':
X print_help();
X exit(0);
END-of-getopt/files/patch-getopt.c
echo x - getopt/files/patch-Makefile
sed 's/^X//' >getopt/files/patch-Makefile << 'END-of-getopt/files/patch-Makefile'
X--- Makefile.orig Thu Jan 23 23:52:29 2003
X+++ Makefile Thu Jun 5 16:17:44 2003
X@@ -1,7 +1,7 @@
X .SUFFIXES:
X
X DESTDIR=
X-prefix=/usr/local
X+prefix=$(PREFIX)
X bindir=$(prefix)/bin
X mandir=$(prefix)/man
X man1dir=$(mandir)/man1
X@@ -29,7 +29,7 @@
X LANGUAGES = cs de es fr it ja nl pt_BR
X MOFILES:=$(patsubst %,po/%.mo,$(LANGUAGES))
X
X-CPPFLAGS=-DLIBCGETOPT=$(LIBCGETOPT) -DWITH_GETTEXT=$(WITH_GETTEXT) -DLOCALEDIR=\"$(localedir)\" -DNOT_UTIL_LINUX
X+CPPFLAGS+=-DLIBCGETOPT=$(LIBCGETOPT) -DWITH_GETTEXT=$(WITH_GETTEXT) -DLOCALEDIR=\"$(localedir)\" -DNOT_UTIL_LINUX
X ifeq ($(LIBCGETOPT),0)
X CPPFLAGS+=-I./gnu
X endif
X@@ -39,8 +39,6 @@
X -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes \
X -Wnested-externs -Winline
X OPTIMIZE=-O3 -fno-strength-reduce
X-CFLAGS=$(WARNINGS) $(OPTIMIZE)
X-LDFLAGS=
X
X sources=getopt.c
X ifeq ($(LIBCGETOPT),0)
X@@ -71,7 +69,7 @@
X getopt-test.bash getopt-test.tcsh \
X $(DESTDIR)$(getoptdir)
X
X-ifeq ($(WITH_GETTEXT),1)
X+ifeq ($(WITHOUT_GETTEXT),0)
X all_po: $(MOFILES)
X install_po: all_po
X $(INSTALL) -m 755 -d $(DESTDIR)$(localedir)
END-of-getopt/files/patch-Makefile
echo x - getopt/Makefile
sed 's/^X//' >getopt/Makefile << 'END-of-getopt/Makefile'
X# New ports collection makefile for: getopt
X# Date created: 2003-06-05
X# Whom: Sergei Kolobov <sergei at kolobov.com>
X#
X# $FreeBSD$
X#
X
XPORTNAME= getopt
XPORTVERSION= 1.1.3
XCATEGORIES= misc
XMASTER_SITES= http://huizen.dds.nl/~frodol/
X
XMAINTAINER= sergei at kolobov.com
XCOMMENT= A getopt(1) replacement that supports GNU-style long options
X
XLIB_DEPENDS= intl:${PORTSDIR}/devel/gettext
X
XUSE_GMAKE= yes
XUSE_GETOPT_LONG= yes
X
XCFLAGS+= -I${LOCALBASE}/include
XLDFLAGS+= -L${LOCALBASE}/lib -lintl
XMAKE_ENV= LIBCGETOPT=0 CFLAGS="${CFLAGS}" LDFLAGS="${LDFLAGS}"
X
XMAN1= getopt.1
XDOCS= Changelog README
X
X.if !defined(NOPORTDOCS)
Xpost-install:
X @${MKDIR} ${DOCSDIR}
X @cd ${WRKSRC} && ${INSTALL_DATA} ${DOCS} ${DOCSDIR}
X.endif
X
X.include <bsd.port.mk>
END-of-getopt/Makefile
echo x - getopt/pkg-plist
sed 's/^X//' >getopt/pkg-plist << 'END-of-getopt/pkg-plist'
X at comment $Id$
Xbin/getopt
X%%PORTDOCS%%%%DOCSDIR%%/Changelog
X%%PORTDOCS%%%%DOCSDIR%%/README
X%%PORTDOCS%%@dirrm %%DOCSDIR%%
Xshare/locale/cs/LC_MESSAGES/getopt.mo
Xshare/locale/de/LC_MESSAGES/getopt.mo
Xshare/locale/es/LC_MESSAGES/getopt.mo
Xshare/locale/fr/LC_MESSAGES/getopt.mo
Xshare/locale/it/LC_MESSAGES/getopt.mo
Xshare/locale/ja/LC_MESSAGES/getopt.mo
Xshare/locale/nl/LC_MESSAGES/getopt.mo
Xshare/locale/pt_BR/LC_MESSAGES/getopt.mo
END-of-getopt/pkg-plist
exit
--- getopt.shar ends here ---
>Release-Note:
>Audit-Trail:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list