* gnulib: Update submodule to latest.
[coreutils.git] / tests / ls / hardlink
blobb1209146646c574c7e8fd2b485ea92ac3aa28479
1 #!/bin/sh
2 # Ensure "ls --color" properly colorizes hard linked files.
4 # Copyright (C) 2008 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 if test "$VERBOSE" = yes; then
20 set -x
21 ls --version
24 . $srcdir/test-lib.sh
25 working_umask_or_skip_
27 touch file file1 || framework_failure
28 ln file1 file2 || skip_test_ "can't create hard link"
29 code_hl='44;37'
30 code_png='01;35'
31 fail=0
33 # regular file - not hard linked
34 LS_COLORS="hl=$code_hl" ls -U1 --color=always file > out || fail=1
35 printf "file\n" > out_ok || fail=1
36 compare out out_ok || fail=1
38 # hard links
39 LS_COLORS="hl=$code_hl" ls -U1 --color=always file1 file2 > out || fail=1
40 printf "\033[0m\033[44;37mfile1\033[0m
41 \033[44;37mfile2\033[0m
42 \033[m" > out_ok || fail=1
43 compare out out_ok || fail=1
45 # hard links and png
46 mv file2 file2.png || framework_failure
47 LS_COLORS="hl=$code_hl:*.png=$code_png" ls -U1 --color=always file1 file2.png > out || fail=1
48 printf "\033[0m\033[44;37mfile1\033[0m
49 \033[44;37mfile2.png\033[0m
50 \033[m" > out_ok || fail=1
51 compare out out_ok || fail=1
53 # hard links and png (hard links highlighting disabled)
54 LS_COLORS="hl=:*.png=$code_png" ls -U1 --color=always file1 file2.png > out || fail=1
55 printf "file1
56 \033[0m\033[01;35mfile2.png\033[0m
57 \033[m" > out_ok || fail=1
58 compare out out_ok || fail=1
60 Exit $fail