*** empty log message ***
[coreutils.git] / tests / mv / update
blob74cd3a21e49c26447387765afa246c1480207fc7
1 #!/bin/sh
2 # make sure --update works as advertised
4 if test "$VERBOSE" = yes; then
5 set -x
6 cp --version
7 mv --version
8 fi
10 . $srcdir/../envvar-check
11 . $srcdir/../lang-default
13 pwd=`pwd`
14 tmp=mv-update.$$
15 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
16 trap '(exit $?); exit' 1 2 13 15
18 framework_failure=0
19 mkdir $tmp || framework_failure=1
20 cd $tmp || framework_failure=1
21 echo old > old || framework_failure=1
22 touch -d yesterday old || framework_failure=1
23 echo new > new || framework_failure=1
25 if test $framework_failure = 1; then
26 echo 'failure in testing framework' 1>&2
27 (exit 1); exit
30 fail=0
32 for cp_or_mv in cp mv; do
33 # This is a no-op.
34 $cp_or_mv --update old new || fail=1
35 case "`cat new`" in new) ;; *) fail=1 ;; esac
36 case "`cat old`" in old) ;; *) fail=1 ;; esac
37 done
39 # This will actually perform the rename.
40 mv --update new old || fail=1
41 test -f new && fail=1
42 case "`cat old`" in new) ;; *) fail=1 ;; esac
44 # Restore initial conditions.
45 echo old > old || fail=1
46 touch -d yesterday old || fail=1
47 echo new > new || fail=1
49 # This will actually perform the copy.
50 cp --update new old || fail=1
51 case "`cat old`" in new) ;; *) fail=1 ;; esac
52 case "`cat new`" in new) ;; *) fail=1 ;; esac
54 (exit $fail); exit