| 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 |
|
|---|
| 8 | if test "$VERBOSE" = yes; then
|
|---|
| 9 | set -x
|
|---|
| 10 | cp --version
|
|---|
| 11 | fi
|
|---|
| 12 |
|
|---|
| 13 | . $srcdir/../envvar-check
|
|---|
| 14 | . $srcdir/../lang-default
|
|---|
| 15 |
|
|---|
| 16 | pwd=`pwd`
|
|---|
| 17 | t0=`echo "$0"|sed 's,.*/,,'`.tmp;tmp=$t0/$$
|
|---|
| 18 | trap 'status=$?; cd $pwd; rm -rf $t0 && exit $status' 0
|
|---|
| 19 | trap '(exit $?); exit' 1 2 13 15
|
|---|
| 20 |
|
|---|
| 21 | framework_failure=0
|
|---|
| 22 | mkdir -p $tmp || framework_failure=1
|
|---|
| 23 | cd $tmp || framework_failure=1
|
|---|
| 24 |
|
|---|
| 25 | mkdir dir || framework_failure=1
|
|---|
| 26 |
|
|---|
| 27 | if test $framework_failure = 1; then
|
|---|
| 28 | echo 'failure in testing framework' 1>&2
|
|---|
| 29 | (exit 1); exit 1
|
|---|
| 30 | fi
|
|---|
| 31 |
|
|---|
| 32 | fail=0
|
|---|
| 33 |
|
|---|
| 34 | # This command should exit nonzero.
|
|---|
| 35 | cp -R dir dir 2> out && fail=1
|
|---|
| 36 |
|
|---|
| 37 | cat > exp <<\EOF
|
|---|
| 38 | cp: cannot copy a directory, `dir', into itself, `dir/dir'
|
|---|
| 39 | EOF
|
|---|
| 40 | #'
|
|---|
| 41 |
|
|---|
| 42 | diff 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.