summaryrefslogtreecommitdiffstats
path: root/usr.bin/head/head.c
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/head/head.c')
-rw-r--r--usr.bin/head/head.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.bin/head/head.c b/usr.bin/head/head.c
index e1caa1f..da3760e 100644
--- a/usr.bin/head/head.c
+++ b/usr.bin/head/head.c
@@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
#include <ctype.h>
#include <err.h>
+#include <getopt.h>
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
@@ -62,6 +63,13 @@ static void head_bytes(FILE *, off_t);
static void obsolete(char *[]);
static void usage(void);
+static const struct option long_opts[] =
+{
+ {"bytes", required_argument, NULL, 'c'},
+ {"lines", required_argument, NULL, 'n'},
+ {NULL, no_argument, NULL, 0}
+};
+
int
main(int argc, char *argv[])
{
@@ -72,7 +80,7 @@ main(int argc, char *argv[])
char *ep;
obsolete(argv);
- while ((ch = getopt(argc, argv, "n:c:")) != -1)
+ while ((ch = getopt_long(argc, argv, "+n:c:", long_opts, NULL)) != -1)
switch(ch) {
case 'c':
bytecnt = strtoimax(optarg, &ep, 10);
OpenPOWER on IntegriCloud