doc: stat: clarify that %t and %T expand to the file system type
[coreutils/ericb.git] / tests / ls / capability
blobda6182076db7371a33595b118c33780f4d911969
1 #!/bin/sh
2 # Ensure "ls --color" properly colorizes file with capability.
4 # Copyright (C) 2008-2011 Free Software Foundation, Inc.
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
19 . "${srcdir=.}/init.sh"; path_prepend_ ../src
20 print_ver_ ls
21 require_root_
23 grep '^#define HAVE_CAP 1' $CONFIG_HEADER > /dev/null \
24 || skip_ "configured without libcap support"
26 (setcap --help) 2>&1 |grep 'usage: setcap' > /dev/null \
27 || skip_ "setcap utility not found"
29 # Don't let a different umask perturb the results.
30 umask 22
32 # We create 2 files of the same name as
33 # before coreutils 8.1 only the name rather than
34 # the full path was used to read the capabilities
35 # thus giving false positives and negatives.
36 mkdir test test/dir
37 cd test
38 touch cap_pos dir/cap_pos dir/cap_neg
39 for file in cap_pos dir/cap_neg; do
40 setcap 'cap_net_bind_service=ep' $file ||
41 skip_ "setcap doesn't work"
42 done
44 code='30;41'
45 # Note we explicitly disable "executable" coloring
46 # so that capability coloring is not dependent on it,
47 # as was the case before coreutils 8.1
48 for ex in '' ex=:; do
49 LS_COLORS="di=:${ex}ca=$code" \
50 ls --color=always cap_pos dir > out || fail=1
52 env printf "\
53 \e[0m\e[${code}mcap_pos\e[0m
55 dir:
56 \e[${code}mcap_neg\e[0m
57 cap_pos
58 " > out_ok || framework_failure_
60 compare out out_ok || fail=1
61 done
63 Exit $fail