*** empty log message ***
[coreutils.git] / tests / rm / isatty
blob31fd0f495758600842703d517e2ceb1a8ab03ca6
1 #!/bin/sh
2 # Make sure `chown 0 f; rm f' prompts before removing f.
4 if test "$VERBOSE" = yes; then
5 set -x
6 rm --version
7 fi
9 . $srcdir/../lang-default
10 PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check
12 pwd=`pwd`
13 t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
14 trap 'status=$?; cd $pwd; rm -rf $t0 && exit $status' 0
15 trap '(exit $?); exit' 1 2 13 15
17 framework_failure=0
18 mkdir -p $tmp || framework_failure=1
19 cd $tmp || framework_failure=1
21 if test $framework_failure = 1; then
22 echo 'failure in testing framework' 1>&2
23 (exit 1); exit
26 fail=0
28 # Skip this test if there is no /dev/stdin file.
29 ls /dev/stdin >/dev/null 2>&1 \
30 || { (exit 77); exit; }
32 touch f
33 chmod 0 f
34 rm --presume-input-tty f > out 2>&1 &
35 pid=$!
37 # Wait a second, to give a buggy rm (as in fileutils-4.0.40)
38 # enough time to remove the file.
39 sleep 1
41 # The file must still exist.
42 test -f f || fail=1
44 kill $pid > /dev/null 2>&1
46 # Note the trailing `x' -- so I don't have to have a trailing
47 # blank in this file :-)
48 cat > exp <<\EOF
49 rm: remove write-protected regular empty file `f'? x
50 EOF
53 # Append an `x' and a newline.
54 echo x >> out
56 cmp out exp || fail=1
57 test $fail = 1 && diff out exp 2> /dev/null
59 (exit $fail); exit