blob: 8750d614a403e78a1c8ce1cfc458f80f8708d5e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
#!/bin/sh
# Test basic --backup functionality -- initially do it just for cp.
# It won't be hard to adapt this script to work for mv, too.
if test "$VERBOSE" = yes; then
set -x
cp --version
fi
LANGUAGE=C; export LANGUAGE
LANG=C; export LANG
umask 022
pwd=`pwd`
actual=actual-$$
expected=expected-$$
dir=dir-$$
trap "cd $pwd; rm -rf $actual $expected $dir" 0 1 2 3 15
mkdir $dir
unset VERSION_CONTROL SIMPLE_BACKUP_SUFFIX
if test "${VERSION_CONTROL+set}" = set; then
echo '$0: the VERSION_CONTROL envvar is set --' \
' unset it and rerun this test' >&2
exit 1;
fi
if test "${SIMPLE_BACKUP_SUFFIX+set}" = set; then
echo '$0: the SIMPLE_BACKUP_SUFFIX envvar is set --' \
' unset it and rerun this test' >&2
>&2
exit 1;
fi
exec 1> $actual
fail=0
for initial_files in 'a' 'a b' 'a b b~' 'a b b.~1~' 'a b b~ b.~1~'; do
for opt in none off numbered t existing nil simple never; do
( cd $dir; touch $initial_files )
cp --backup=$opt $dir/a $dir/b || fail=1
( cd $dir; echo $initial_files $opt: `ls a b*`; rm -f a b b~ b.~?~ )
done
done
cat <<\EOF > $expected
a none: a b
a off: a b
a numbered: a b
a t: a b
a existing: a b
a nil: a b
a simple: a b
a never: a b
a b none: a b
a b off: a b
a b numbered: a b b.~1~
a b t: a b b.~1~
a b existing: a b b~
a b nil: a b b~
a b simple: a b b~
a b never: a b b~
a b b~ none: a b b~
a b b~ off: a b b~
a b b~ numbered: a b b.~1~ b~
a b b~ t: a b b.~1~ b~
a b b~ existing: a b b~
a b b~ nil: a b b~
a b b~ simple: a b b~
a b b~ never: a b b~
a b b.~1~ none: a b b.~1~
a b b.~1~ off: a b b.~1~
a b b.~1~ numbered: a b b.~1~ b.~2~
a b b.~1~ t: a b b.~1~ b.~2~
a b b.~1~ existing: a b b.~1~ b.~2~
a b b.~1~ nil: a b b.~1~ b.~2~
a b b.~1~ simple: a b b.~1~ b~
a b b.~1~ never: a b b.~1~ b~
a b b~ b.~1~ none: a b b.~1~ b~
a b b~ b.~1~ off: a b b.~1~ b~
a b b~ b.~1~ numbered: a b b.~1~ b.~2~ b~
a b b~ b.~1~ t: a b b.~1~ b.~2~ b~
a b b~ b.~1~ existing: a b b.~1~ b.~2~ b~
a b b~ b.~1~ nil: a b b.~1~ b.~2~ b~
a b b~ b.~1~ simple: a b b.~1~ b~
a b b~ b.~1~ never: a b b.~1~ b~
EOF
# Uncomment this if you see a failure and want to try to diagnose it.
# diff -u $expected $actual 1>&2
cmp $expected $actual || fail=1
exit $fail
|