1#!/bin/sh 2# prior to coreutils-4.5.3, du -D didn't work in some cases 3# Based on an example from Andreas Schwab and/or Michal Svec. 4# Also, up to coreutils-8.5, du -L sometimes incorrectly 5# counted the space of the followed symlinks. 6 7# Copyright (C) 2002-2023 Free Software Foundation, Inc. 8 9# This program is free software: you can redistribute it and/or modify 10# it under the terms of the GNU General Public License as published by 11# the Free Software Foundation, either version 3 of the License, or 12# (at your option) any later version. 13 14# This program is distributed in the hope that it will be useful, 15# but WITHOUT ANY WARRANTY; without even the implied warranty of 16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17# GNU General Public License for more details. 18 19# You should have received a copy of the GNU General Public License 20# along with this program. If not, see <https://www.gnu.org/licenses/>. 21 22. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src 23print_ver_ du 24 25mkdir -p a/sub || framework_failure_ 26ln -s a/sub slink || framework_failure_ 27touch b || framework_failure_ 28ln -s .. a/sub/dotdot || framework_failure_ 29ln -s nowhere dangle || framework_failure_ 30 31 32# This used to fail with the following diagnostic: 33# du: 'b': No such file or directory 34du -sD slink b > /dev/null 2>&1 || fail=1 35 36# This used to fail to report the dangling symlink. 37returns_ 1 du -L dangle > /dev/null 2>&1 || fail=1 38 39# du -L used to mess up, either by counting the symlink's file system space 40# itself (-L should follow symlinks, not count their space) 41# or (briefly in July 2010) by omitting the entry for "a". 42du_L_output=$(du -L a) || fail=1 43du_lL_output=$(du -lL a) || fail=1 44du_x_output=$(du --exclude=dotdot a) || fail=1 45test "X$du_L_output" = "X$du_x_output" || fail=1 46test "X$du_lL_output" = "X$du_x_output" || fail=1 47 48Exit $fail 49