Tizen 2.0 Release
[external/tizen-coreutils.git] / tests / ls / color-dtype-dir
1 #!/bin/sh
2 # Ensure "ls --color" properly colors other-writable and sticky directories.
3 # Before coreutils-6.2, this test would fail, coloring all three
4 # directories the same as the first one -- but only on a file system
5 # with dirent.d_type support.
6
7 # Copyright (C) 2006 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 2 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, write to the Free Software
21 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 # 02110-1301, USA.
23
24 if test "$VERBOSE" = yes; then
25   set -x
26   ls --version
27 fi
28
29 . $srcdir/../envvar-check
30
31 pwd=`pwd`
32 t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$
33 trap 'status=$?; cd "$pwd" && chmod -R u+rwx $t0 && rm -rf $t0 && exit $status' 0
34 trap '(exit $?); exit $?' 1 2 13 15
35
36 framework_failure=0
37 mkdir -p $tmp || framework_failure=1
38 cd $tmp || framework_failure=1
39
40 mkdir d other-writable sticky || framework_failure=1
41 chmod o+w other-writable || framework_failure=1
42 chmod o+t sticky || framework_failure=1
43
44 if test $framework_failure = 1; then
45   echo "$0: failure in testing framework" 1>&2
46   (exit 1); exit 1
47 fi
48
49 fail=0
50
51 ls --color=always > out || fail=1
52 cat -A out > o1 || fail=1
53 echo >> o1 || fail=1
54 mv o1 out || fail=1
55
56 cat <<\EOF > exp || fail=1
57 ^[[0m^[[01;34md^[[0m$
58 ^[[34;42mother-writable^[[0m$
59 ^[[0mout^[[0m$
60 ^[[37;44msticky^[[0m$
61 ^[[m
62 EOF
63
64 cmp out exp || fail=1
65 test $fail = 1 && diff out exp 2> /dev/null
66
67 (exit $fail); exit $fail