update from savannah
[coreutils.git] / tests / touch / relative
blobd996cd455d289a93806eaae50e2b63db319056ed
1 #!/bin/sh
2 # Demonstrate using a combination of --reference and --date to
3 # set the time of a file back by an arbitrary amount.
5 if test "$VERBOSE" = yes; then
6 set -x
7 touch --version
8 fi
10 . $srcdir/../envvar-check
12 pwd=`pwd`
13 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
14 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; 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
20 TZ=UTC0 touch --date='2004-01-16 12:00 +0000' f || framework_failure=1
22 if test $framework_failure = 1; then
23 echo "$0: failure in testing framework" 1>&2
24 (exit 1); exit 1
27 fail=0
29 # Set times back by 5 days.
30 touch --ref f --date='-5 days' f || fail=1
32 TZ=UTC0 ls -og --time-style=+%Y-%m-%d f > out.1 || fail
33 sed 's/ f$//;s/.* //' out.1 > out
35 cat <<\EOF > exp || fail=1
36 2004-01-11
37 EOF
39 cmp out exp || fail=1
40 test $fail = 1 && diff out exp 2> /dev/null
42 (exit $fail); exit $fail