coreutils/tests/cp/backup-1

41 lines
876 B
Plaintext
Raw Normal View History

1997-07-09 07:00:29 +08:00
#!/bin/sh
1997-07-10 02:11:59 +08:00
if test "$VERBOSE" = yes; then
set -x
cp --version
1997-07-10 02:11:59 +08:00
fi
2002-04-20 05:38:32 +08:00
pwd=`pwd`
t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
trap 'status=$?; cd $pwd; rm -rf $t0 && exit $status' 0
2002-04-20 05:38:32 +08:00
trap '(exit $?); exit' 1 2 13 15
framework_failure=0
mkdir -p $tmp || framework_failure=1
cd $tmp || framework_failure=1
if test $framework_failure = 1; then
2002-10-08 17:21:08 +08:00
echo "$0: failure in testing framework" 1>&2
(exit 1); exit 1
2002-04-20 05:38:32 +08:00
fi
1997-07-09 07:00:29 +08:00
suffix=.b
2002-04-20 05:38:32 +08:00
file=b1.$$
file_backup="$file$suffix"
temp_files="$file $file_backup"
1997-07-09 07:04:58 +08:00
rm -f $temp_files
1997-07-09 07:00:29 +08:00
1997-07-09 07:04:58 +08:00
fail=0
2002-04-20 05:38:32 +08:00
echo test > $file || fail=1
1997-07-09 07:00:29 +08:00
1997-07-09 07:06:36 +08:00
# Specify both version control and suffix so the environment variables
# (possibly set by the user running these tests) aren't used.
2002-04-20 05:38:32 +08:00
cp --force --backup=simple --suffix=$suffix $file $file \
1997-07-09 07:04:58 +08:00
|| fail=1
1997-07-09 07:00:29 +08:00
2002-04-20 05:38:32 +08:00
test -f $file || fail=1
test -f $file_backup || fail=1
cmp $file $file_backup > /dev/null || fail=1
1997-07-09 07:04:58 +08:00
(exit $fail); exit $fail