tests: factor 350 fail=0 initializations into test-lib.sh
[platform/upstream/coreutils.git] / tests / rm / dangling-symlink
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.
6
7 # Copyright (C) 2002, 2004-2006, 2008-2009 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 <http://www.gnu.org/licenses/>.
21
22 if test "$VERBOSE" = yes; then
23   set -x
24   rm --version
25 fi
26
27 . $srcdir/test-lib.sh
28
29 ln -s no-file dangle
30 ln -s / symlink
31
32
33 rm ---presume-input-tty dangle symlink &
34 pid=$!
35 # The buggy rm (fileutils-4.1.9) would hang here, waiting for input.
36
37 # Give the working rm a chance to remove the file.
38 sleep 1
39
40 # The file must no longer exist.
41 ls -l dangle > /dev/null 2>&1 && fail=1
42 ls -l symlink > /dev/null 2>&1 && fail=1
43
44 kill $pid > /dev/null 2>&1
45
46 Exit $fail