if _have_tput ; then
COLS="$("$TPUT" cols)"
if [ -n "$COLS" ]; then
- COL=$(( "$COLS" - 7 ))
+ COL=$(( $COLS - 7 ))
else
COL=73
fi
if [ -r /proc/cmdline ] ; then
grep -q ' nocolor' /proc/cmdline && RC_NOCOLOR='yes'
fi
+[ -n "$NOCOLORS" ] && RC_NOCOLOR='yes'
RC_NOCOLOR="${RC_NOCOLOR:-no}"
# Can the terminal handle endcols?
fi
if [ "${RC_ENDCOL}" = "yes" ]; then
- ENDCOL="\e[A\e[$(( "${COLS}" - 8 ))G"
+ ENDCOL="\e[A\e[$(( ${COLS} - 8 ))G"
else
ENDCOL=''
fi
local pri
local tag
+ [ "$#" -le 2 ] && return 0
if [ -x /usr/bin/logger ] ; then
pri="$1"
tag="$2"
-
shift 2
- [ "$#" -eq 0 ] && return 0
/usr/bin/logger -p "${pri}" -t "${tag}" -- "$@"
fi
# increase the indent used for e-commands.
#
eindent() {
- local i="$1"
+ local i="${1:-0}"
[ "$i" -gt 0 ] || i="${RC_DEFAULT_INDENT}"
- esetdent $(( ${#RC_INDENTATION} + "$i" ))
+ esetdent $(( ${#RC_INDENTATION} + $i ))
}
# void eoutdent(int num)
# decrease the indent used for e-commands.
#
eoutdent() {
- local i="$1"
+ local i="${1:-0}"
[ "$i" -gt 0 ] || i="${RC_DEFAULT_INDENT}"
- esetdent $(( ${#RC_INDENTATION} - "$i" ))
+ esetdent $(( ${#RC_INDENTATION} - $i ))
}
# void esetdent(int num)
# num defaults to 0
#
esetdent() {
- local i="$1"
+ local i="${1:-0}"
[ "$i" -lt 0 ] && i=0
RC_INDENTATION="$(printf "%${i}s" '')"
}
[ "${RC_QUIET_STDOUT}" = "yes" ] && return 0
if [ -n "${RC_DOT_PATTERN}" ]; then
- dots="$(printf "%$(( "$COLS" - 3 - ${#RC_INDENTATION} - ${#msg} - 7 ))s" '')"
+ dots="$(printf "%$(( $COLS - 3 - ${#RC_INDENTATION} - ${#msg} - 7 ))s" '')"
while [ "${dots#${spaces}}" != "${dots}" ] ; do
dots="${dots#${spaces}}${RC_DOT_PATTERN}"
done
printf "${ENDCOL} ${msg}\n"
else
[ "${LAST_E_CMD}" = "ebegin" ] || LAST_E_LEN=0
- printf "%$(( "${COLS}" - "${LAST_E_LEN}" - 6 ))s%b\n" '' "${msg}"
+ printf "%$(( ${COLS} - ${LAST_E_LEN} - 6 ))s%b\n" '' "${msg}"
fi
return "${retval}"