~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/mv/trailing-slash.sh

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# On some operating systems, e.g. SunOS-4.1.1_U1 on sun3x,
 
3
# rename() doesn't accept trailing slashes.
 
4
# Also, ensure that "mv dir non-exist-dir/" works.
 
5
# Also, ensure that "cp dir non-exist-dir/" works.
 
6
 
 
7
# Copyright (C) 2004-2012 Free Software Foundation, Inc.
 
8
 
 
9
# This program is free software: you can redistribute it and/or modify
 
10
# it under the terms of the GNU General Public License as published by
 
11
# the Free Software Foundation, either version 3 of the License, or
 
12
# (at your option) any later version.
 
13
 
 
14
# This program is distributed in the hope that it will be useful,
 
15
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
16
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
17
# GNU General Public License for more details.
 
18
 
 
19
# You should have received a copy of the GNU General Public License
 
20
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
21
 
 
22
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 
23
print_ver_ mv
 
24
 
 
25
mkdir foo || framework_failure_
 
26
 
 
27
 
 
28
mv foo/ bar || fail=1
 
29
 
 
30
# mv and cp would misbehave for coreutils versions [5.3.0..5.97], 6.0 and 6.1
 
31
for cmd in mv 'cp -r'; do
 
32
  for opt in '' -T -u; do
 
33
    rm -rf d e || framework_failure_
 
34
    mkdir d    || framework_failure_
 
35
 
 
36
    $cmd $opt d e/ || fail=1
 
37
    if test "$cmd" = mv; then
 
38
      test -d d && fail=1
 
39
    else
 
40
      test -d d || fail=1
 
41
    fi
 
42
    test -d e || fail=1
 
43
  done
 
44
done
 
45
 
 
46
# We would like the erroneous-looking "mv any non-dir/" to fail,
 
47
# but with the current implementation, it depends on how the
 
48
# underlying rename syscall handles the trailing slash.
 
49
# It does fail, as desired, on recent Linux and Solaris systems.
 
50
#touch a a2
 
51
#mv a a2/ && fail=1
 
52
 
 
53
# Test for a cp-specific diagnostic introduced after coreutils-8.7:
 
54
printf '%s\n' \
 
55
  "cp: cannot create regular file 'no-such/': Not a directory" \
 
56
> expected-err
 
57
touch b
 
58
cp b no-such/ 2> err && fail=1
 
59
 
 
60
# Map "No such file..." diagnostic to the expected "Not a directory"
 
61
sed 's/No such file or directory/Not a directory/' err > k && mv k err
 
62
 
 
63
compare expected-err err || fail=1
 
64
 
 
65
Exit $fail