source: trunk/coreutils/tests/cp/into-self@ 2565

Last change on this file since 2565 was 2565, checked in by bird, 20 years ago

line ending fuckup.

File size: 1.0 KB
Line 
1#!/bin/sh
2# Confirm that copying a directory into itself gets a proper diagnostic.
3# In 4.0.35 and earlier, `mkdir dir && cp -R dir dir' would produce this:
4# cp: won't create hard link `dir/dir/dir' to directory `'
5# Now it gives this:
6# cp: can't copy a directory `dir' into itself `dir/dir'
7
8if test "$VERBOSE" = yes; then
9 set -x
10 cp --version
11fi
12
13. $srcdir/../envvar-check
14. $srcdir/../lang-default
15
16pwd=`pwd`
17t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
18trap 'status=$?; cd $pwd; rm -rf $t0 && exit $status' 0
19trap '(exit $?); exit' 1 2 13 15
20
21framework_failure=0
22mkdir -p $tmp || framework_failure=1
23cd $tmp || framework_failure=1
24
25mkdir dir || framework_failure=1
26
27if test $framework_failure = 1; then
28 echo 'failure in testing framework' 1>&2
29 (exit 1); exit 1
30fi
31
32fail=0
33
34# This command should exit nonzero.
35cp -R dir dir 2> out && fail=1
36
37cat > exp <<\EOF
38cp: cannot copy a directory, `dir', into itself, `dir/dir'
39EOF
40#'
41
42diff out exp 2> /dev/null || fail=1 #bird cmp -> diff
43#test $fail = 1 && diff out exp 2> /dev/null #bird
44
45(exit $fail); exit $fail
Note: See TracBrowser for help on using the repository browser.