coreutils/tests/cp/backup-is-src

40 lines
780 B
Plaintext
Raw Normal View History

1998-05-11 11:46:48 +08:00
#!/bin/sh
if test "$VERBOSE" = yes; then
set -x
cp --version
1998-05-11 11:46:48 +08:00
fi
2002-04-20 06:36:11 +08:00
. $srcdir/../lang-default
. $srcdir/../envvar-check
2002-04-20 06:36:11 +08:00
pwd=`pwd`
t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
trap 'status=$?; cd $pwd; rm -rf $t0 && exit $status' 0
trap '(exit $?); exit' 1 2 13 15
1998-05-11 11:46:48 +08:00
framework_failure=0
2002-04-20 06:36:11 +08:00
mkdir -p $tmp || framework_failure=1
cd $tmp || framework_failure=1
echo a > a || framework_failure=1
echo a-tilde > a~ || framework_failure=1
1998-05-11 11:46:48 +08:00
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
1998-05-11 11:46:48 +08:00
fi
# This cp command should exit nonzero.
cp --b=simple a~ a > out 2>&1 && fail=1
1998-05-11 11:46:48 +08:00
sed "s,cp:,XXX:," out > out2
1998-05-11 11:46:48 +08:00
cat > exp <<\EOF
XXX: backing up `a' would destroy source; `a~' not copied
EOF
cmp out2 exp || fail=1
(exit $fail); exit $fail