855ca908852311e7be60032dfc92787bcdafa4f7
[platform/upstream/coreutils.git] / tests / ls / m-option
1 #!/bin/sh
2 # exercise the -m option
3
4 if test "$VERBOSE" = yes; then
5   set -x
6   ls --version
7 fi
8
9 . $srcdir/../envvar-check
10
11 pwd=`pwd`
12 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
13 trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0
14 trap '(exit $?); exit $?' 1 2 13 15
15
16 framework_failure=0
17 mkdir -p $tmp || framework_failure=1
18 cd $tmp || framework_failure=1
19 seq 2000 > b || framework_failure=1
20 touch a || framework_failure=1
21
22 if test $framework_failure = 1; then
23   echo "$0: failure in testing framework" 1>&2
24   (exit 1); exit 1
25 fi
26
27 fail=0
28
29 # Before coreutils-5.1.1, the following would output a space after the comma.
30 ls -w2 -m a b > out || fail=1
31
32 # Before coreutils-5.1.1, the following would produce leading white space.
33 # All of the sed business is because the sizes are not portable.
34 ls -sm a b | sed 's/^[0-9]/0/;s/, [0-9][0-9]* b/, 12 b/' >> out || fail=1
35 cat <<\EOF > exp || fail=1
36 a,
37 b
38 0 a, 12 b
39 EOF
40
41 cmp out exp || fail=1
42 test $fail = 1 && diff out exp 2> /dev/null
43
44 (exit $fail); exit $fail