tests: avoid false failure in tail inotify test
[coreutils.git] / tests / misc / wc-files0.sh
blob12b7d6afe8f725884bca92f7bf7270445ff1edb0
1 #!/bin/sh
2 # Show that wc's new --files0-from option works.
4 # Copyright (C) 2006-2016 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 . "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
20 print_ver_ wc
22 echo 2 > 2b || framework_failure_
23 echo 2 words > 2w || framework_failure_
24 printf '2b\n2w\n' |tr '\n' '\0' > names || framework_failure_
27 wc --files0-from=names > out || fail=1
28 cat <<\EOF > exp || fail=1
29 1 1 2 2b
30 1 2 8 2w
31 2 3 10 total
32 EOF
34 compare exp out || fail=1
36 if ! test "$fail" = 1; then
37 # Repeat the above test, but read the file name list from stdin.
38 rm -f out
39 wc --files0-from=- < names > out || fail=1
40 compare exp out || fail=1
43 # Ensure file name containing new lines are output on a single line
44 nlname='1
46 touch "$nlname" || framework_failure_
47 printf '%s\0' "$nlname" | wc --files0-from=- > out || fail=1
48 printf '%s\n' "0 0 0 '1'$'\\n''2'" > exp || framework_failure_
49 compare exp out || fail=1
51 Exit $fail