1
0
mirror of git://git.sv.gnu.org/coreutils.git synced 2026-06-07 18:26:35 +02:00
Files
coreutils/tests/mv/into-self
T

58 lines
1.0 KiB
Bash
Raw Normal View History

1998-03-14 10:37:29 +00:00
#! /bin/sh
1998-08-16 03:05:01 +00:00
# Demonstrate how mv fails when it tries to move a directory into itself.
1998-03-14 10:37:29 +00:00
1998-11-30 00:46:14 +00:00
if test "$VERBOSE" = yes; then
set -x
1999-11-27 10:14:04 +00:00
mv --version
1998-11-30 00:46:14 +00:00
fi
1998-03-14 10:37:29 +00:00
dir=into-self-dir
file=into-self-file
test_failure=0
1999-11-27 10:14:04 +00:00
rm -rf $dir $file || test_failure=1
mkdir -p $dir/a/b || test_failure=1
touch $file || test_failure=1
1998-03-14 10:37:29 +00:00
if test $test_failure = 1; then
echo 'failure in testing framework'
exit 1
fi
fail=0
1998-08-16 03:05:01 +00:00
# Make sure we get English translations.
LANGUAGE=C
export LANGUAGE
LC_ALL=C
export LC_ALL
LANG=C
export LANG
# This mv command should fail.
1999-11-27 10:14:04 +00:00
mv $dir $file $dir > out 2>&1 && fail=1
1998-08-16 03:05:01 +00:00
sed \
1999-11-27 10:14:04 +00:00
-e "s,mv:,XXX:," \
1998-08-16 03:05:01 +00:00
-e "s,$dir,SRC," \
-e "s,$dir/$dir,DEST," \
out > out2
cat > exp <<\EOF
XXX: cannot move `SRC' to a subdirectory of itself, `DEST'
EOF
cmp out2 exp || fail=1
1998-03-14 10:37:29 +00:00
# Make sure the file is gone.
test -f $file && fail=1
1998-08-16 03:05:01 +00:00
# Make sure the directory is *not* moved.
test -d $dir || fail=1
test -d $dir/$dir && fail=1
1998-03-14 10:37:29 +00:00
# Make sure the file has been moved to the right place.
test -f $dir/$file || fail=1
1999-11-27 10:14:04 +00:00
rm -rf $dir $file out out2 exp
1998-03-14 10:37:29 +00:00
exit $fail