Permalink
Browse files

lib.bash: simplify prefix condition

  • Loading branch information...
1 parent 4297577 commit 13702cbac71e86f82f74a359593531df8c4063f3 @grawity committed Mar 7, 2014
Showing with 3 additions and 5 deletions.
  1. +3 −5 bin/lib.bash
View
8 bin/lib.bash
@@ -30,10 +30,9 @@ print_msg() {
color=$3 reset=${color:+'\e[m'}
fi
if [[ $DEBUG ]]; then
- local progname="$progname[$$]"
+ local progname="$progname[$$]" progname_prefix=1
fi
- if [[ $DEBUG || $progname_prefix -gt 0 ||
- ( $progname_prefix -le 0 && $_lvl -gt 0 ) ]]; then
+ if (( progname_prefix > 0 || ( progname_prefix < 0 && _lvl ) )); then
nprefix="$progname: "
fi
printf "%s${color}%s:${reset} %s\n" "$nprefix" "$prefix" "$msg"
@@ -48,8 +47,7 @@ print_fmsg() {
if [[ -t 1 ]]; then
color="$fcolor" reset='\e[m'
fi
- if [[ $progname_prefix -gt 0 ||
- ( $progname_prefix -le 0 && $_lvl -gt 0 ) ]]; then
+ if (( progname_prefix > 0 || ( progname_prefix < 0 && _lvl ) )); then
nprefix="$progname: "
fi
printf "%s${color}%s${reset} %s\n" "$nprefix" "$fprefix" "$msg"

0 comments on commit 13702cb

Please sign in to comment.