summaryrefslogtreecommitdiffstats
path: root/usr.bin/look/look.c
diff options
context:
space:
mode:
authoreadler <eadler@FreeBSD.org>2014-07-04 04:47:29 +0000
committereadler <eadler@FreeBSD.org>2014-07-04 04:47:29 +0000
commitea17ba82898dc418b74fe344924fff6885747f33 (patch)
treeb6e8d22e320865618636c0871311d8444098e340 /usr.bin/look/look.c
parent955dea01221af057f350ceb93cb8fe85d61d0fde (diff)
downloadFreeBSD-src-ea17ba82898dc418b74fe344924fff6885747f33.zip
FreeBSD-src-ea17ba82898dc418b74fe344924fff6885747f33.tar.gz
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
Diffstat (limited to 'usr.bin/look/look.c')
-rw-r--r--usr.bin/look/look.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/usr.bin/look/look.c b/usr.bin/look/look.c
index 5f830d0..ada6e25 100644
--- a/usr.bin/look/look.c
+++ b/usr.bin/look/look.c
@@ -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 */
OpenPOWER on IntegriCloud