# HG changeset patch # User Rob Landley # Date 1426791422 18000 # Node ID 0c30e5484516079fa1362c16cf02031d7256d629 # Parent da1296acc73eecb2b5426d6a604f0aaae70318ea Add -123 support to head (suggested by Elliott Hughes). diff -r da1296acc73e -r 0c30e5484516 toys/posix/head.c --- a/toys/posix/head.c Wed Mar 18 16:32:01 2015 -0500 +++ b/toys/posix/head.c Thu Mar 19 13:57:02 2015 -0500 @@ -4,7 +4,7 @@ * * See http://opengroup.org/onlinepubs/9699919799/utilities/head.html -USE_HEAD(NEWTOY(head, "n#<0=10", TOYFLAG_BIN)) +USE_HEAD(NEWTOY(head, "?n#<0=10", TOYFLAG_BIN)) config HEAD bool "head" @@ -50,5 +50,12 @@ void head_main(void) { - loopfiles(toys.optargs, do_head); + char *arg = *toys.optargs; + + // handle old "-42" style arguments + if (arg && *arg == '-' && arg[1]) { + TT.lines = atolx(arg+1); + toys.optc--; + } + loopfiles(toys.optargs+!!arg, do_head); }