blob: 752b15f22d88120562f4617ab1b87cf040cda72a (
plain)
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
|
#!/bin/bash
#
# Script for command output colorization
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#
# @(#) [MB] cr_hl_generic Version 1.12 du 15/11/08 -
#
# This script calls the original programme with all the arguments
# it received, and pipes it to "hl" using its name as the "hl"
# configuration.
#
# In case the user doesn't want the output of the command to
# be colorized, the following syntax must be used :
# USE_HL=no cmd [args ...]
#
OUT=/tmp/OUT.$$
ERR=/tmp/ERR.$$
mknod $OUT p
mknod $ERR p
case "$USE_HL" in
n|N|no|NO|0) USE_HL="no"
;;
esac
progname="$(basename $0)"
pathname="$(type -p "$progname")"
dirname="$(dirname "$pathname")"
PATH="$(echo "$PATH" | sed "s|^$dirname:||;s|:$dirname:|:|g")"
export PATH
if [ "$WHICH" = 1 ]; then
type "$progname"
exit 1
fi
if [ "$USE_HL" = "no" ]; then
# No colorization
# ~~~~~~~~~~~~~~~
"$progname" "$@"
rc=$?
else
# Default behaviour : colorization
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
hl -u --"$progname" < "$ERR" & hl --"$progname" < "$OUT" & \
"$progname" "$@" > "$OUT" 2> "$ERR"
rc=$?
fi
wait
rm -f "$OUT" "$ERR"
exit $rc
|