Commit e34eef71 authored by Paul Cammish's avatar Paul Cammish
Browse files

Strip escape codes from logs

parent 1eed44fe
......@@ -41,7 +41,7 @@ _echo() {
}
_log() {
echo "$@" >> $LOG
echo "$@" | sed 's|\\033[[0-9;]*m||g' >> $LOG
}
_pass() {
......@@ -88,16 +88,16 @@ _test_error() {
_centre() {
spacer="$1"
line="$2"
stripped_line="$( echo $line | sed 's|\\033[[0-9;]*m||g' )"
if [ $VERBOSE ]; then
col="$( tput cols )" || col=80
col=$((col - 3))
stripped_line="$( echo $line | sed 's|\\033[[0-9;]*m||g' )"
len=$(( ( col / 2 ) - ( ( ${#stripped_line} + 1 ) / 2 ) ))
echo -e "\033[2m$(for each in $(seq 1 $len); do printf "$spacer"; done)\033[0m $line \033[2m$(for each in $(seq 1 $len); do printf "$spacer"; done)\033[0m"
fi
col=78
len=$(( ( col / 2 ) - ( ( ${#line} + 1 ) / 2 ) ))
_log "$(for each in $(seq 1 $len); do printf "$spacer"; done) $line $(for each in $(seq 1 $len); do printf "$spacer"; done)" | cut -c 1-$((col))
len=$(( ( col / 2 ) - ( ( ${#stripped_line} + 1 ) / 2 ) ))
_log "$(for each in $(seq 1 $len); do printf "$spacer"; done) $stripped_line $(for each in $(seq 1 $len); do printf "$spacer"; done)" | cut -c 1-$((col))
}
#############################################################################
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment