tests: use "Exit $fail", not (exit $fail); exit $fail
[coreutils/bo.git] / tests / du / hard-link
blobd58adbe44f1d0cfbcdd7d5baa33374fd58edf901
1 #!/bin/sh
2 # Ensure that hard-linked files are counted (and listed) only once.
3 # Likewise for excluded directories.
4 # Ensure that hard links _are_ listed twice when using --count-links.
6 # Copyright (C) 2003, 2006-2008 Free Software Foundation, Inc.
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 if test "$VERBOSE" = yes; then
22 set -x
23 du --version
26 . $srcdir/test-lib.sh
28 mkdir -p dir/sub
29 ( cd dir && { echo non-empty > f1; ln f1 f2; echo non-empty > sub/F; } )
31 fail=0
33 # Note that for this first test, we transform f1 or f2
34 # (whichever name we find first) to f_. That is necessary because,
35 # depending on the type of file system, du could encounter either of those
36 # two hard-linked files first, thus listing that one and not the other.
37 du -a --exclude=sub dir \
38 | sed 's/^[0-9][0-9]* //' | sed 's/f[12]/f_/' > out || fail=1
39 echo === >> out
40 du -a --exclude=sub --count-links dir \
41 | sed 's/^[0-9][0-9]* //' | sort -r >> out || fail=1
42 cat <<\EOF > exp
43 dir/f_
44 dir
45 ===
46 dir/f2
47 dir/f1
48 dir
49 EOF
51 compare out exp || fail=1
53 Exit $fail