1#!/bin/bash 2 3[ -f testing.sh ] && . testing.sh 4 5#testing "name" "command" "result" "infile" "stdin" 6 7testing "nl" "nl" " 1\tone\n 2\ttwo\n 3\tthree\n" \ 8 "" "one\ntwo\nthree\n" 9 10testing "nl explicit defaults" "nl -nrn -b a" \ 11 " 1\tone\n 2\ttwo\n 3\tthree\n" "" "one\ntwo\nthree\n" 12 13# -n ln rn rz 14 15testing "nl -nln" "nl -nln" "1 \tone\n2 \ttwo\n3 \tthree\n" \ 16 "" "one\ntwo\nthree\n" 17testing "nl -nln -w" "nl -nln -w 8" \ 18 "1 \tone\n2 \ttwo\n3 \tthree\n" "" "one\ntwo\nthree\n" 19 20testing "nl -nrz" "nl -nrz" "000001\tone\n000002\ttwo\n000003\tthree\n" \ 21 "" "one\ntwo\nthree\n" 22 23testing "nl -nrz -w" "nl -w3 -nrz" "001\tone\n002\ttwo\n003\tthree\n" \ 24 "" "one\ntwo\nthree\n" 25 26 27# For non-matching lines the separator is "suppressed" meaning it... 28# turns into spaces! And the tab turns into one space, and -d boom turns 29# into 4 spaces, but these: 30# nl -s"$(echo -e 'bo\tom')" -bpand README 31# nl -w 3 -bpthe README 32# Yeah. And I doubt utf8 fontmetrics are used either. 33 34testing "nl -b t" "nl -b t" " \n 1\tone\n \n 2\ttwo\n" \ 35 "" "\none\n\ntwo\n" 36testing "nl -b n" "nl -b n" " one\n two\n three\n" \ 37 "" "one\ntwo\nthree\n" 38testing "nl -sook -b p" "nl -sook -bpoing" \ 39 " one\n 1ookboing\n 2ooksproingy\n" \ 40 "" "one\nboing\nsproingy\n" 41 42testing "nl -v" "nl -v 42" " 42\tone\n 43\ttwo\n 44\tthree\n" \ 43 "" "one\ntwo\nthree\n" 44testing "nl -l" "nl -ba -l2 -w2 - input" \ 45 " 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" \ 46 "\n\nbang\n\n" "one\n\n\ntwo\n\n\n\nthree\nfour\n\n" 47testing "nl no space" "nl -w 1 -v 42" "42\tline\n" "" "line\n" 48 49# Should test for -E but no other implementation seems to have it? 50#testing "nl -E" "nl -w2 -sx -Ebp'(one|two)'" " 1x" "one\nand\ntwo\n" 51