This time with a test.
---
tests/tail.test | 1 +
toys/posix/tail.c | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
From 0ffc6f5afb4a0293cabab97de7000a4260c08270 Mon Sep 17 00:00:00 2001
From: Elliott Hughes <[email protected]>
Date: Sat, 16 Apr 2016 08:19:23 -0700
Subject: [PATCH] Fix tail -NUM again.
This time with a test.
---
tests/tail.test | 1 +
toys/posix/tail.c | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/tests/tail.test b/tests/tail.test
index c1c44c6..81dc871 100755
--- a/tests/tail.test
+++ b/tests/tail.test
@@ -20,6 +20,7 @@ testing "-c out of bounds" "tail -c 999 file1" "$BIGTEST" "" ""
testing "-c+ in bounds" "tail -c +27 file1" \
"x\nseven\neight\nnine\nten\neleven\n" "" ""
testing "-c+ out of bonds" "tail -c +999 file1" "" "" ""
+testing "-N" "tail -1 file1" "eleven\n" "" ""
rm file1
testing "stdin no trailing newline" "tail -n 1 - " "c" "" "a\nb\nc"
diff --git a/toys/posix/tail.c b/toys/posix/tail.c
index 1204f1c..787e116 100644
--- a/toys/posix/tail.c
+++ b/toys/posix/tail.c
@@ -231,10 +231,10 @@ void tail_main(void)
if (arg && *arg == '-' && arg[1]) {
TT.lines = atolx(*(args++));
toys.optc--;
+ } else {
+ // if nothing specified, default -n to -10
+ TT.lines = -10;
}
-
- // if nothing specified, default -n to -10
- TT.lines = -10;
}
// Allocate 2 ints per optarg for -f
--
2.8.0.rc3.226.g39d4020
_______________________________________________
Toybox mailing list
[email protected]
http://lists.landley.net/listinfo.cgi/toybox-landley.net