/usr/bin/colorit is in dict 1.12.0+dfsg-4build1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 | #!/bin/sh
#
# Written by Aleksey Cheusov <vle@gmx.net>
#
sysconfdir=/etc/dictd
if test -r $HOME/.coloritrc; then
config_file=$HOME/.coloritrc
else if test -r "$sysconfdir/colorit.conf"; then
config_file="$sysconfdir/colorit.conf"
else
echo "configuration file is not readable" > "/dev/stderr"
exit 1
fi fi
usage (){
printf "\
colorit is intended to markup stdin or input files\n\
and output result to stdout\n\
\n\
usage: colorit [OPTIONS] [files...]\n\
OPTIONS:\n\
-h --help display this screen\n\
-V --verbose display version\n\
-c --config specify a configuration file\n\
--pp specify preprocessor (- for none). The default is \"m4\"\n\
"
}
version (){
printf "\
colorit 0.0.1\n\
"
}
pp='m4'
while test $# -ne 0; do
case $1 in
-h|--help)
usage
exit 0;;
-V|--version)
version
exit 0;;
-c|--config)
config_file=$2
shift;;
-P|--pager)
pager=$2
if test "$pager" != -; then
echo '--pager option is now deprecated' 1>&2
exit 1
fi
shift;;
--pp)
pp=$2;
shift;;
--)
shift
break;;
-*)
echo "unknown argument '$1'" 1>&2
break;;
*)
break;;
esac
shift
done
if test "_$pp" = "_-"; then
pp=
fi
convert_files_to_stdout (){
gawk -v config_file="$config_file" -v pp="$pp" '
BEGIN {
for (i=1; i <= ARGC; ++i){
if (ARGV [i] == "--help"){
usage()
exit 1
}
if (ARGV [i] == "--version"){
version()
exit 1
}
if (ARGV [i] == "--config" || ARGV [i] == "-c"){
config_file = ARGV [i + 1]
ARGV [i] = ARGV [i + 1] = ""
++i
continue
}
}
}
BEGIN {
mark_count = 0
}
function do_esc (s){
gsub(/\\033/, "\033", s)
return s
}
function do_unquote (s) {
if (s ~ /^".*"$/ || s ~ /^`.*`$/){
return substr(s, 2, length(s)-2)
}else{
return s
}
}
function process_config_mark ( ok, arr){
ok = match($0, /mark +("[^"]+"|`[^`]+`|[^ ]+) +("[^"]+"|`[^`]+`|[^ ]+) +("[^"]+"|`[^`]+`|[^ ]+) *$/, arr)
if (ok){
mark_repl[mark_count] = "&"
mark_re [mark_count] = do_unquote(arr [1])
mark_beg [mark_count] = do_esc(do_unquote(arr [2]))
mark_end [mark_count] = do_esc(do_unquote(arr [3]))
++mark_count
return 1
}else{
return 0
}
}
function process_config_gensub ( ok, arr){
ok = match($0, /^gensub +("[^"]+"|`[^`]+`|[^ ]+) +("[^"]+"|`[^`]+`|[^ ]+) *$/, arr)
if (ok){
mark_repl[mark_count] = do_esc(do_unquote(arr [1]))
mark_re [mark_count] = do_unquote(arr [2])
mark_beg [mark_count] = ""
mark_end [mark_count] = ""
++mark_count
return 1
}else{
return 0
}
}
function process_config_line (){
sub(/^#.*$/, "")
if (NF == 0)
return
if ($1 == "mark"){
if (!process_config_mark()){
print "missing arguments to `mark` at line:\n`" $0 "`" > "/dev/stderr"
exit 1
}
}else if ($1 == "gensub"){
if (!process_config_gensub()){
print "missing arguments to `gensub` at line:\n`" $0 "`" > "/dev/stderr"
exit 1
}
}else{
print "unexpected command `" $1 "`" > "/dev/stderr"
exit 2
}
}
function process_config (){
if (pp == ""){
pipe = "cat < \"" config_file "\""
while (0 < (ret = (pipe | getline))){
process_config_line()
}
}else{
pipe = pp " -DHOME=" ENVIRON ["HOME"] " <\"" config_file "\""
while (0 < (ret = (pipe | getline))){
process_config_line()
}
close(pipe)
}
}
BEGIN {
process_config()
}
{
for (i=0; i < mark_count; ++i){
cnt = gsub(mark_re [i], (mark_beg [i] "&" mark_end [i]))
}
print $0
} ' "$@"
}
convert_files_to_stdout "$@"
|