1#!/bin/sh 2# Show that wc's new --files0-from option works. 3 4# Copyright (C) 2006-2023 Free Software Foundation, Inc. 5 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. 10 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. 15 16# You should have received a copy of the GNU General Public License 17# along with this program. If not, see <https://www.gnu.org/licenses/>. 18 19. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src 20print_ver_ wc 21 22echo 2 > 2b || framework_failure_ 23echo 2 words > 2w || framework_failure_ 24printf '2b\n2w\n' |tr '\n' '\0' > names || framework_failure_ 25 26 27wc --files0-from=names > out || fail=1 28cat <<\EOF > exp || framework_failure_ 29 1 1 2 2b 30 1 2 8 2w 31 2 3 10 total 32EOF 33 34compare exp out || fail=1 35 36if ! 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 41fi 42 43# Ensure file name containing new lines are output on a single line 44nlname='1 452' 46touch "$nlname" || framework_failure_ 47printf '%s\0' "$nlname" | wc --files0-from=- > out || fail=1 48printf '%s\n' "0 0 0 '1'\$'\\n''2'" > exp || framework_failure_ 49compare exp out || fail=1 50 51# Ensure correct byte counts, which fails between v8.24 and v8.26 inclusive 52truncate -s1G wc.big || framework_failure_ 53touch wc.small || framework_failure_ 54printf '%s\0' wc.big wc.small | wc -c --files0-from=- >out || fail=1 55cat <<\EOF > exp || framework_failure_ 561073741824 wc.big 570 wc.small 581073741824 total 59EOF 60compare exp out || fail=1 61 62Exit $fail 63