781b5a951a11f67c6a2a619e22f9f9923b258b7d
[platform/upstream/coreutils.git] / tests / touch / no-create-missing
1 #!/bin/sh
2 # Ensure that touch -c no-such-file no longer fails (it did in 4.1.8).
3
4 if test "$VERBOSE" = yes; then
5   set -x
6   touch --version
7 fi
8
9 pwd=`pwd`
10 tmp=`echo "$0"|sed 's,.*/,,'`.tmp
11 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
12 trap '(exit $?); exit' 1 2 13 15
13
14 framework_failure=0
15 mkdir $tmp || framework_failure=1
16 cd $tmp || framework_failure=1
17
18 if test $framework_failure = 1; then
19   echo "$0: failure in testing framework" 1>&2
20   (exit 1); exit 1
21 fi
22
23 fail=0
24
25 touch -c no-file > /dev/null 2>&1 || fail=1
26 touch -cm no-file > /dev/null 2>&1 || fail=1
27 touch -ca no-file > /dev/null 2>&1 || fail=1
28
29 # If >&- works, test "touch -c -" etc.
30 # >&- apparently does not work in HP-UX 11.23.
31 # This test is ineffective unless /dev/stdout also works.
32 if $pwd/../../src/test -w /dev/stdout >/dev/null &&
33    $pwd/../../src/test ! -w /dev/stdout >&-; then
34   touch -c - >&- 2> /dev/null || fail=1
35   touch -cm - >&- 2> /dev/null || fail=1
36   touch -ca - >&- 2> /dev/null || fail=1
37 fi
38
39 (exit $fail); exit $fail