2001-08-06 15:50:45 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
# make sure --update works as advertised
|
|
|
|
|
|
2010-01-01 10:56:28 +01:00
|
|
|
# Copyright (C) 2001, 2004, 2006-2010 Free Software Foundation, Inc.
|
2006-08-17 19:58:17 +00:00
|
|
|
|
2007-07-23 14:35:58 +02:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
2006-08-17 19:58:17 +00:00
|
|
|
# it under the terms of the GNU General Public License as published by
|
2007-07-23 14:35:58 +02:00
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
2006-08-17 19:58:17 +00:00
|
|
|
# (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
2007-07-23 14:35:58 +02:00
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2006-08-17 19:58:17 +00:00
|
|
|
|
2001-08-06 15:50:45 +00:00
|
|
|
if test "$VERBOSE" = yes; then
|
|
|
|
|
set -x
|
2001-08-07 11:31:06 +00:00
|
|
|
cp --version
|
2001-08-06 15:50:45 +00:00
|
|
|
mv --version
|
|
|
|
|
fi
|
|
|
|
|
|
2008-05-27 13:45:44 +02:00
|
|
|
. $srcdir/test-lib.sh
|
2001-08-06 15:50:45 +00:00
|
|
|
|
2007-09-06 23:05:16 +02:00
|
|
|
echo old > old || framework_failure
|
|
|
|
|
touch -d yesterday old || framework_failure
|
|
|
|
|
echo new > new || framework_failure
|
2001-08-06 15:50:45 +00:00
|
|
|
|
|
|
|
|
|
2007-07-19 10:14:41 +02:00
|
|
|
for interactive in '' -i; do
|
|
|
|
|
for cp_or_mv in cp mv; do
|
|
|
|
|
# This is a no-op, with no prompt.
|
|
|
|
|
# With coreutils-6.9 and earlier, using --update with -i would
|
|
|
|
|
# mistakenly elicit a prompt.
|
|
|
|
|
$cp_or_mv $interactive --update old new < /dev/null > out 2>&1 || fail=1
|
|
|
|
|
test -s out && fail=1
|
|
|
|
|
case "`cat new`" in new) ;; *) fail=1 ;; esac
|
|
|
|
|
case "`cat old`" in old) ;; *) fail=1 ;; esac
|
|
|
|
|
done
|
2001-08-07 11:31:06 +00:00
|
|
|
done
|
2001-08-06 15:50:45 +00:00
|
|
|
|
2001-08-07 11:31:06 +00:00
|
|
|
# This will actually perform the rename.
|
2001-08-06 15:50:45 +00:00
|
|
|
mv --update new old || fail=1
|
|
|
|
|
test -f new && fail=1
|
|
|
|
|
case "`cat old`" in new) ;; *) fail=1 ;; esac
|
|
|
|
|
|
2001-08-07 11:32:28 +00:00
|
|
|
# Restore initial conditions.
|
|
|
|
|
echo old > old || fail=1
|
|
|
|
|
touch -d yesterday old || fail=1
|
|
|
|
|
echo new > new || fail=1
|
|
|
|
|
|
2001-08-07 11:31:06 +00:00
|
|
|
# This will actually perform the copy.
|
|
|
|
|
cp --update new old || fail=1
|
|
|
|
|
case "`cat old`" in new) ;; *) fail=1 ;; esac
|
|
|
|
|
case "`cat new`" in new) ;; *) fail=1 ;; esac
|
|
|
|
|
|
2008-09-07 10:31:27 +02:00
|
|
|
Exit $fail
|