look: implement long options
gentoo has "util-linux 2.24.1" with long options. Other distributions have similar. usage() is intentionally unchanged to keep it short and sweet Reviewed by: jmg Discussed with: adrian, jilles
This commit is contained in:
parent
955dea0122
commit
ea17ba8289
@ -63,12 +63,12 @@ alphabetic characters is ignored.
|
||||
.Pp
|
||||
The following options are available:
|
||||
.Bl -tag -width indent
|
||||
.It Fl d
|
||||
.It Fl d , -alphanum
|
||||
Dictionary character set and order, i.e., only alphanumeric characters
|
||||
are compared.
|
||||
.It Fl f
|
||||
.It Fl f , -ignore-case
|
||||
Ignore the case of alphabetic characters.
|
||||
.It Fl t
|
||||
.It Fl t , -terminate Ar termchar
|
||||
Specify a string termination character, i.e., only the characters
|
||||
in
|
||||
.Ar string
|
||||
@ -106,7 +106,9 @@ implementation.
|
||||
.Pp
|
||||
The
|
||||
.Fl a
|
||||
flag is ignored for compability.
|
||||
and
|
||||
.Fl -alternative
|
||||
flags are ignored for compability.
|
||||
.Sh SEE ALSO
|
||||
.Xr grep 1 ,
|
||||
.Xr sort 1
|
||||
|
@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <err.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <getopt.h>
|
||||
#include <limits.h>
|
||||
#include <locale.h>
|
||||
#include <stdint.h>
|
||||
@ -88,6 +89,14 @@ static void print_from(wchar_t *, unsigned char *, unsigned char *);
|
||||
|
||||
static void usage(void);
|
||||
|
||||
static struct option longopts[] = {
|
||||
{ "alternative",no_argument, NULL, 'a' },
|
||||
{ "alphanum", no_argument, NULL, 'd' },
|
||||
{ "ignore-case",no_argument, NULL, 'i' },
|
||||
{ "terminate", required_argument, NULL, 't'},
|
||||
{ NULL, 0, NULL, 0 },
|
||||
};
|
||||
|
||||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
@ -102,7 +111,7 @@ main(int argc, char *argv[])
|
||||
|
||||
file = _path_words;
|
||||
termchar = L'\0';
|
||||
while ((ch = getopt(argc, argv, "adft:")) != -1)
|
||||
while ((ch = getopt_long(argc, argv, "+adft:", longopts, NULL)) != -1)
|
||||
switch(ch) {
|
||||
case 'a':
|
||||
/* COMPATIBILITY */
|
||||
|
Loading…
Reference in New Issue
Block a user