Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Apr 2018 18:55:02 +0000 (UTC)
From:      Kyle Evans <kevans@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r333122 - head/usr.bin/seq
Message-ID:  <201804301855.w3UIt2UK065006@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kevans
Date: Mon Apr 30 18:55:01 2018
New Revision: 333122
URL: https://svnweb.freebsd.org/changeset/base/333122

Log:
  seq(1): Provide some long options
  
  These match GNU seq(1) names where applicable for compatibility purposes.
  
  MFC after:	1 month

Modified:
  head/usr.bin/seq/seq.1
  head/usr.bin/seq/seq.c

Modified: head/usr.bin/seq/seq.1
==============================================================================
--- head/usr.bin/seq/seq.1	Mon Apr 30 17:33:44 2018	(r333121)
+++ head/usr.bin/seq/seq.1	Mon Apr 30 18:55:01 2018	(r333122)
@@ -29,7 +29,7 @@
 .\"
 .\" $FreeBSD$
 .\"
-.Dd August 12, 2016
+.Dd April 30, 2018
 .Dt SEQ 1
 .Os
 .Sh NAME
@@ -72,7 +72,7 @@ The
 .Nm
 utility accepts the following options:
 .Bl -tag -width Ar
-.It Fl f Ar format
+.It Fl f Ar format , Fl -format Ar format
 Use a
 .Xr printf 3
 style
@@ -98,7 +98,7 @@ defined in
 .St -ansiC .
 The default is
 .Cm %g .
-.It Fl s Ar string
+.It Fl s Ar string , Fl -separator Ar string
 Use
 .Ar string
 to separate numbers.
@@ -109,7 +109,7 @@ defined in
 .St -ansiC .
 The default is
 .Cm \en .
-.It Fl t Ar string
+.It Fl t Ar string , Fl -terminator Ar string
 Use
 .Ar string
 to terminate sequence of numbers.
@@ -121,7 +121,7 @@ defined in
 This option is useful when the default separator
 does not contain a
 .Cm \en .
-.It Fl w
+.It Fl w , Fl -fixed-width
 Equalize the widths of all numbers by padding with zeros as necessary.
 This option has no effect with the
 .Fl f

Modified: head/usr.bin/seq/seq.c
==============================================================================
--- head/usr.bin/seq/seq.c	Mon Apr 30 17:33:44 2018	(r333121)
+++ head/usr.bin/seq/seq.c	Mon Apr 30 18:55:01 2018	(r333122)
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
 #include <ctype.h>
 #include <err.h>
 #include <errno.h>
+#include <getopt.h>
 #include <math.h>
 #include <locale.h>
 #include <stdio.h>
@@ -67,6 +68,15 @@ static int valid_format(const char *);
 static char *generate_format(double, double, double, int, char);
 static char *unescape(char *);
 
+static const struct option long_opts[] =
+{
+	{"format",	required_argument,	NULL, 'f'},
+	{"separator",	required_argument,	NULL, 's'},
+	{"terminator",	required_argument,	NULL, 't'},
+	{"equal-width",	no_argument,		NULL, 'w'},
+	{NULL,		no_argument,		NULL, 0}
+};
+
 /*
  * The seq command will print out a numeric sequence from 1, the default,
  * to a user specified upper limit by 1.  The lower bound and increment
@@ -100,7 +110,7 @@ main(int argc, char *argv[])
          * least they trip up getopt(3).
          */
 	while ((optind < argc) && !numeric(argv[optind]) &&
-	    (c = getopt(argc, argv, "f:hs:t:w")) != -1) {
+	    (c = getopt_long(argc, argv, "+f:hs:t:w", long_opts, NULL)) != -1) {
 
 		switch (c) {
 		case 'f':	/* format (plan9) */



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