[Secure-testing-commits] r20099 - bin
Raphael Geissert
geissert at alioth.debian.org
Wed Sep 5 17:50:25 UTC 2012
Author: geissert
Date: 2012-09-05 17:50:24 +0000 (Wed, 05 Sep 2012)
New Revision: 20099
Modified:
bin/gen-DSA
Log:
Use colours on notice, warning, and error messages
It makes them easier to notice.
Modified: bin/gen-DSA
===================================================================
--- bin/gen-DSA 2012-09-05 17:37:28 UTC (rev 20098)
+++ bin/gen-DSA 2012-09-05 17:50:24 UTC (rev 20099)
@@ -63,6 +63,30 @@
sort -n | tr "\n" ' ' | sed -r 's/\s+/ /g;s/\s$//'
}
+warn() {
+ printf "${YELLOW}warning:${NORMAL} %s\n" "$1"
+}
+
+notice() {
+ printf "${MAGENTA}notice:${NORMAL} %s\n" "$1"
+}
+
+error() {
+ printf "${RED}error:${NORMAL} %s\n" "$1"
+}
+
+if which tput >/dev/null; then
+ RED=$(tput setaf 1)
+ YELLOW=$(tput setaf 3)
+ MAGENTA=$(tput setaf 5)
+ NORMAL=$(tput op)
+else
+ RED=''
+ YELLOW=''
+ MAGENTA=''
+ NORMAL=''
+fi
+
PACKAGE="$(tolower "$1")"
VULNERABILITY="$2"
CVE="$(toupper "$3")"
@@ -79,7 +103,7 @@
for id in $CVE; do
grep -wq "^$id" data/CVE/list || {
- echo "warning: '$id' is not known" >&2
+ warn "'$id' is not known" >&2
}
done
@@ -88,7 +112,7 @@
:
;;
*)
- echo "warning: missing DSA revision number, assuming 1" >&2
+ notice "missing DSA revision number, assuming 1" >&2
DSAID="$DSAID-1"
;;
esac
@@ -105,8 +129,8 @@
dsa=$(($dsa+1))
c=$(($c+1))
if [ $c -eq 10 ]; then
- echo "error: unable to find an unused DSA id after $c attempts" >&2
- echo "to workaround specify an id as the first parameter" >&2
+ error "unable to find an unused DSA id after $c attempts" >&2
+ error "to workaround specify an id as the first parameter" >&2
exit 1
fi
done
@@ -114,19 +138,19 @@
fi
if dsa_exists "$DSAID"; then
- echo "error: DSA-$DSAID has already been used" >&2
+ error "DSA-$DSAID has already been used" >&2
exit 1
fi
if which aspell >/dev/null && echo test | aspell -l en list 2>/dev/null; then
echo "$VULNERABILITY" | aspell -l en list |
while read word; do
- echo "Possible spelling mistake: $word!" >&2
+ warn "possible spelling mistake: $word!" >&2
done
elif which enchant >/dev/null && echo test | enchant -l -d en 2>/dev/null; then
echo "$VULNERABILITY" | enchant -l -d en |
while read word; do
- echo "Possible spelling mistake: $word!" >&2
+ warn "possible spelling mistake: $word!" >&2
done
fi
More information about the Secure-testing-commits
mailing list