tests: fix help-version on cygwin, where $EXEEXT is nonempty
[coreutils/ericb.git] / tests / rm / dangling-symlink
blob92a59066adadb2b67f9a57e27548e53e4a6282e3
1 #!/bin/sh
2 # rm should not prompt before removing a dangling symlink.
3 # Likewise for a non-dangling symlink.
4 # But for fileutils-4.1.9, it would do the former and
5 # for fileutils-4.1.10 the latter.
7 # Copyright (C) 2002-2012 Free Software Foundation, Inc.
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.
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.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 . "${srcdir=.}/init.sh"; path_prepend_ ../src
23 print_ver_ rm
25 ln -s no-file dangle
26 ln -s / symlink
29 rm ---presume-input-tty dangle symlink &
30 pid=$!
31 # The buggy rm (fileutils-4.1.9) would hang here, waiting for input.
33 # Wait up to 3.1s for rm to remove the files
34 check_files_removed() {
35 local delay="$1"
36 local present=0
37 ls -l dangle > /dev/null 2>&1 && present=1
38 ls -l symlink > /dev/null 2>&1 && present=1
39 test $present = 1 && { sleep $delay; return 1; } || :
41 retry_delay_ check_files_removed .1 5 || fail=1
43 kill $pid > /dev/null 2>&1
45 Exit $fail