~ubuntu-branches/ubuntu/utopic/coreutils/utopic-proposed

« back to all changes in this revision

Viewing changes to tests/ls/multihardlink.sh

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2012-11-28 03:03:42 UTC
  • mfrom: (8.3.4 sid)
  • Revision ID: package-import@ubuntu.com-20121128030342-21zanj8354gas5gr
Tags: 8.20-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Make 'uname -i -p' return the real processor/hardware, instead of
    unknown.
  - Build-depend on gettext:any instead of on gettext, so that apt-get can
    properly resolve build-dependencies on the tool when cross-building.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
# Ensure "ls --color" properly colorizes hard linked files.
 
3
 
 
4
# Copyright (C) 2008-2012 Free Software Foundation, Inc.
 
5
 
 
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.
 
10
 
 
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.
 
15
 
 
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/>.
 
18
 
 
19
. "${srcdir=.}/tests/init.sh"; path_prepend_ ./src
 
20
print_ver_ ls
 
21
working_umask_or_skip_
 
22
 
 
23
touch file file1 || framework_failure_
 
24
ln file1 file2 || skip_ "can't create hard link"
 
25
code_mh='44;37'
 
26
code_ex='01;32'
 
27
code_png='01;35'
 
28
c0=$(printf '\033[0m')
 
29
c_mh=$(printf '\033[%sm' $code_mh)
 
30
c_ex=$(printf '\033[%sm' $code_ex)
 
31
c_png=$(printf '\033[%sm' $code_png)
 
32
 
 
33
# regular file - not hard linked
 
34
LS_COLORS="mh=$code_mh" ls -U1 --color=always file > out || fail=1
 
35
printf "file\n" > out_ok || framework_failure_
 
36
compare out out_ok || fail=1
 
37
 
 
38
# hard links
 
39
LS_COLORS="mh=$code_mh" ls -U1 --color=always file1 file2 > out || fail=1
 
40
printf "$c0${c_mh}file1$c0
 
41
${c_mh}file2$c0
 
42
" > out_ok || framework_failure_
 
43
compare out out_ok || fail=1
 
44
 
 
45
# hard links and png (hard link coloring takes precedence)
 
46
mv file2 file2.png || framework_failure_
 
47
LS_COLORS="mh=$code_mh:*.png=$code_png" ls -U1 --color=always file1 file2.png \
 
48
  > out || fail=1
 
49
printf "$c0${c_mh}file1$c0
 
50
${c_mh}file2.png$c0
 
51
" > out_ok || framework_failure_
 
52
compare out out_ok || fail=1
 
53
 
 
54
# hard links and exe (exe coloring takes precedence)
 
55
chmod a+x file2.png || framework_failure_
 
56
LS_COLORS="mh=$code_mh:*.png=$code_png:ex=$code_ex" \
 
57
  ls -U1 --color=always file1 file2.png > out || fail=1
 
58
chmod a-x file2.png || framework_failure_
 
59
printf "$c0${c_ex}file1$c0
 
60
${c_ex}file2.png$c0
 
61
" > out_ok || framework_failure_
 
62
compare out out_ok || fail=1
 
63
 
 
64
# hard links and png (hard link coloring disabled => png coloring enabled)
 
65
LS_COLORS="mh=00:*.png=$code_png" ls -U1 --color=always file1 file2.png > out \
 
66
  || fail=1
 
67
printf "file1
 
68
$c0${c_png}file2.png$c0
 
69
" > out_ok || framework_failure_
 
70
compare out out_ok || fail=1
 
71
 
 
72
# hard links and png (hard link coloring not enabled explicitly => png coloring)
 
73
LS_COLORS="*.png=$code_png" ls -U1 --color=always file1 file2.png > out \
 
74
  || fail=1
 
75
printf "file1
 
76
$c0${c_png}file2.png$c0
 
77
" > out_ok || framework_failure_
 
78
compare out out_ok || fail=1
 
79
 
 
80
Exit $fail