1 #!/bin/bash 2 3 [ -f testing.sh ] && . testing.sh 4 5 #testing "name" "command" "result" "infile" "stdin" 6 7 testing "stdin" "strings" "foobar\n" "" "foobar\n" 8 testing "file" "strings input" "foobar\n" "foobar\n" "" 9 testing "string to the end" "strings input" "foobar\n" "foobar" "" 10 testing "short strings" "strings input" "" "foo\nbar\n" "" 11 testing "-n6" "strings -n6 input" "foobar\n" "foobar\nbaz\n" "" 12 testing "string and nulls" "strings input" "foobar\nbazfoo\n" \ 13 "\0foobar\0\0bazfoo\0foo" "" 14 testing "-f" "strings -f input" "input: foobar\n" "foobar\n" "" 15 testing "-o" "strings -o input | sed 's/^ *//'" "6 foobar\n" \ 16 "\0\0\0\0\0\0foobar\n" "" 17 testing "-o, multiple strings" "strings -n3 -o input | sed 's/^ *//'" \ 18 "1 foo\n7 bar\n" "\0foo\0b\0bar\n" "" 19 testing "-fo" "strings -fo input | sed 's/: */: /'" "input: 6 foobar\n" \ 20 "\0\0\0\0\0\0foobar\n" "" 21 22 OFFSET_10="\0\0\0\0\0\0\0\0\0\0foobar\n" 23 testing "-t o" "strings -t o | sed 's/^ *//'" "12 foobar\n" "" $OFFSET_10 24 testing "-t d" "strings -t d | sed 's/^ *//'" "10 foobar\n" "" $OFFSET_10 25 testing "-t x" "strings -t x | sed 's/^ *//'" "a foobar\n" "" $OFFSET_10 26