forked from trapd00r/LS_COLORS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildsuite
executable file
·131 lines (113 loc) · 2.95 KB
/
buildsuite
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#!/usr/bin/env bash
# GNU bash, version 4.3.18(1)-release (x86_64-unknown-linux-gnu)
#
# © Copyright 2014 Ryan Delaney.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Functions {{{1
lscolors_buildsuite_print_extensions() {
sed -e '/^[ ]+#/d; /^[^\.\*]/d; /^$/d; s/^\([\.\*][^ ]+\).*/\1/' ../LS_COLORS
}
verbose() {
if [[ "$verbose" = "1" ]]; then
echo "$1" >&2
fi
}
error() {
echo "$1" >&2
}
# }}}
# Usage {{{1
#
usage() {
cat <<EOD
buildtest
Web site: http://github.com/trapd00r/LS_COLORS
© Copyright 2014 Ryan Delaney.
buildtest builds a test suite for LS_COLORS
Usage: buildtest [OPTION]
Options
-?, --help print this help and exit
-v, --verbose increase verbosity
EOD
exit 1
}
# }}}
# Parameters {{{1
#
while :
do
case $1 in
--help | -\?)
usage
exit 0
;;
-v | --verbose)
# Each instance of -v adds 1 to verbosity
local verbose=$((verbose+1))
shift
;;
--) # End of all options
shift
break
;;
-*)
echo "FATAL: Unknown option : $1" >&2
exit 1
shift
;;
*) # no more options. Stop while loop
break
;;
esac
done
# }}}
# Dependencies {{{
if ! type sed &> /dev/null; then echo "ERROR: Missing dependency: sed" 1>&2; exit 1; fi
# }}}
if [[ ! -d "./test" ]]; then mkdir test || exit 1; fi
cd test || exit 1
# File
if [[ ! -f FILE ]]; then touch FILE; fi
# Executable file
if [[ ! -f EXECUTABLE ]]; then touch EXECUTABLE; fi
chmod +x EXECUTABLE
# Symlink
if [[ ! -f SYMLINK ]]; then ln -s FILE SYMLINK; fi
# Directory
if [[ ! -d DIRECTORY ]]; then mkdir DIRECTORY; fi
# Directory symlink
if [[ ! -d DIR-SYMLINK ]]; then ln -s DIRECTORY DIR-SYMLINK; fi
# Hardlink
if [[ ! -f HARDLINK1 ]]; then touch HARDLINK1; fi
if [[ ! -f HARDLINK2 ]]; then ln HARDLINK1 HARDLINK2; fi
# Create a link to nowhere
if [[ ! -f nothing ]]; then touch nothing; fi
if [[ ! -f ORPHAN ]]; then ln -s nothing ORPHAN; fi
if [[ -f nothing ]]; then rm nothing; fi
# World-writable
if [[ ! -f WORLDWRITEABLE ]]; then touch WORLDWRITEABLE; fi
chmod 0777 WORLDWRITEABLE
# Supported extensions
while read line; do
if [[ ! -f test"$line" ]]; then
line="${line//\*/.}"
if [[ "${line:0:1}" == "." ]]; then
touch ./DIRECTORY/test"$line"
else
touch ./DIRECTORY/"$line"
fi
fi
done < <( lscolors_buildsuite_print_extensions )
# vim: ft=sh foldmethod=marker: