[Toybox] [PATCH] nl: nl -v
Eric Molitor
emolitor at molitor.org
Wed Jul 3 01:33:45 PDT 2019
Implement nl -v supporting negative and zero starting values.
--- ../toybox-0.8.1-bak/tests/nl.test 2019-06-29 13:17:36.381513304 +0100
+++ ./tests/nl.test 2019-07-03 09:30:24.221718523 +0100
@@ -39,8 +39,13 @@
" one\n 1ookboing\n 2ooksproingy\n" \
"" "one\nboing\nsproingy\n"
-testing "-v" "nl -v 42" " 42\tone\n 43\ttwo\n 44\tthree\n" \
+testing "-v42" "nl -v 42" " 42\tone\n 43\ttwo\n 44\tthree\n" \
"" "one\ntwo\nthree\n"
+testing "-v-1" "nl -v -1" " -1\tone\n 0\ttwo\n 1\tthree\n" \
+ "" "one\ntwo\nthree\n"
+testing "-v0" "nl -v 0" " 0\tone\n 1\ttwo\n 2\tthree\n" \
+ "" "one\ntwo\nthree\n"
+
testing "-l" "nl -ba -l2 -w2 - input" \
" 1\tone\n \n 2\t\n 3\ttwo\n \n 4\t\n \n 5\tthree\n 6\tfour\n \n
7\t\n \n 8\tbang\n \n" \
"\n\nbang\n\n" "one\n\n\ntwo\n\n\n\nthree\nfour\n\n"
Only in .: test.txt
diff -ru ../toybox-0.8.1-bak/toys/posix/nl.c ./toys/posix/nl.c
--- ../toybox-0.8.1-bak/toys/posix/nl.c 2019-06-29 13:17:36.389513344 +0100
+++ ./toys/posix/nl.c 2019-07-03 09:07:16.690362502 +0100
@@ -5,15 +5,15 @@
* See http://pubs.opengroup.org/onlinepubs/9699919799/utilities/nl.html
*
* This implements a subset: only one logical page (-ip), no sections
(-dfh).
- * todo: -lv
+ * todo: -l
-USE_NL(NEWTOY(nl, "v#<1=1l#w#<0=6Eb:n:s:", TOYFLAG_USR|TOYFLAG_BIN))
+USE_NL(NEWTOY(nl, "v#=1l#w#<0=6Eb:n:s:", TOYFLAG_USR|TOYFLAG_BIN))
config NL
bool "nl"
default y
help
- usage: nl [-E] [-l #] [-b MODE] [-n STYLE] [-s SEPARATOR] [-w WIDTH]
[FILE...]
+ usage: nl [-E] [-l #] [-b MODE] [-n STYLE] [-s SEPARATOR] [-v #] [-w
WIDTH] [FILE...]
Number lines of input.
@@ -22,6 +22,7 @@
-l Only count last of this many consecutive blank lines
-n Number STYLE: ln (left justified) rn (right justified) rz (zero pad)
-s Separator to use between number and line (instead of TAB)
+ -v Starting line number for each section (default 1)
-w Width of line numbers (default 6)
*/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20190703/403710fd/attachment.htm>
More information about the Toybox
mailing list