a9940b71f91adf0eb3a919918fc81ff4dee3e1e3
[platform/upstream/coreutils.git] / tests / misc / split-a
1 #!/bin/sh
2 # Show that split -a works.
3
4 if test "$VERBOSE" = yes; then
5   set -x
6   split --version
7 fi
8
9 pwd=`pwd`
10 tmp=split-a.$$
11 trap 'status=$?; cd $pwd; rm -rf $tmp && exit $status' 0
12 trap '(exit $?); exit' 1 2 13 15
13
14 framework_failure=0
15 mkdir $tmp || framework_failure=1
16 cd $tmp || framework_failure=1
17
18 if test $framework_failure = 1; then
19   echo "$0: failure in testing framework" 1>&2
20   (exit 1); exit 1
21 fi
22
23 fail=0
24
25 # Generate a 27-byte file
26 # yes|tr -d y|head -n27 > in
27 echo abcdefghijklmnopqrstuvwxyz > in
28
29 # This should fail.
30 split -b 1 -a 1 in 2> err && fail=1
31 test -f xa || fail=1
32 test -f xz || fail=1
33 test -f xaa && fail=1
34 test -f xaz && fail=1
35 rm -f x*
36
37 # With a longer suffix, it must succeed.
38 split --verbose -b 1 -a 2 in 2> err || fail=1
39 test -f xaa || fail=1
40 test -f xaz || fail=1
41 test -f xba || fail=1
42 test -f xbb && fail=1
43
44 cat <<\EOF > exp
45 creating file `xaa'
46 creating file `xab'
47 creating file `xac'
48 creating file `xad'
49 creating file `xae'
50 creating file `xaf'
51 creating file `xag'
52 creating file `xah'
53 creating file `xai'
54 creating file `xaj'
55 creating file `xak'
56 creating file `xal'
57 creating file `xam'
58 creating file `xan'
59 creating file `xao'
60 creating file `xap'
61 creating file `xaq'
62 creating file `xar'
63 creating file `xas'
64 creating file `xat'
65 creating file `xau'
66 creating file `xav'
67 creating file `xaw'
68 creating file `xax'
69 creating file `xay'
70 creating file `xaz'
71 creating file `xba'
72 EOF
73
74 cmp err exp || fail=1
75 test $fail = 1 && diff err exp 2> /dev/null
76
77 (exit $fail); exit $fail