aboutsummaryrefslogtreecommitdiff
path: root/toys/posix
diff options
context:
space:
mode:
Diffstat (limited to 'toys/posix')
-rw-r--r--toys/posix/head.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/toys/posix/head.c b/toys/posix/head.c
index e8517d44..42f945bf 100644
--- a/toys/posix/head.c
+++ b/toys/posix/head.c
@@ -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 @@ static void do_head(int fd, char *name)
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);
}