mirror of
https://gitlab.com/sortix/sortix.git
synced 2023-02-13 20:55:38 -05:00
Support historical syntax in head(1) and tail(1).
This commit is contained in:
parent
89b02af091
commit
79799b0084
1 changed files with 14 additions and 2 deletions
16
utils/tail.c
16
utils/tail.c
|
@ -20,6 +20,7 @@
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
|
|
||||||
|
#include <ctype.h>
|
||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <getopt.h>
|
#include <getopt.h>
|
||||||
|
@ -348,14 +349,25 @@ int main(int argc, char* argv[])
|
||||||
{"verbose", no_argument, NULL, 'v'},
|
{"verbose", no_argument, NULL, 'v'},
|
||||||
{0, 0, 0, 0}
|
{0, 0, 0, 0}
|
||||||
};
|
};
|
||||||
int opt;
|
|
||||||
#ifndef HEAD
|
#ifndef HEAD
|
||||||
const char* opts = "c:fFn:qv";
|
const char* opts = "c:fFn:qv";
|
||||||
#else
|
#else
|
||||||
const char* opts = "c:n:qv";
|
const char* opts = "c:n:qv";
|
||||||
#endif
|
#endif
|
||||||
while ( (opt = getopt_long(argc, argv, opts, longopts, NULL)) != -1 )
|
while ( true )
|
||||||
{
|
{
|
||||||
|
// Handle the historical but still widely used -num option format.
|
||||||
|
if ( optind < argc && argv[optind][0] == '-' &&
|
||||||
|
isdigit((unsigned char) argv[optind][1]) )
|
||||||
|
{
|
||||||
|
parse_number(&argv[optind][1]);
|
||||||
|
optind++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
int opt = getopt_long(argc, argv, opts, longopts, NULL);
|
||||||
|
if ( opt == -1 )
|
||||||
|
break;
|
||||||
switch ( opt )
|
switch ( opt )
|
||||||
{
|
{
|
||||||
case 'c':
|
case 'c':
|
||||||
|
|
Loading…
Reference in a new issue