Skip to content

Commit

Permalink
lib.bash: simplify prefix condition
Browse files Browse the repository at this point in the history
  • Loading branch information
grawity committed Mar 7, 2014
1 parent 4297577 commit 13702cb
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions bin/lib.bash
Expand Up @@ -30,10 +30,9 @@ print_msg() {
color=$3 reset=${color:+'\e[m'} color=$3 reset=${color:+'\e[m'}
fi fi
if [[ $DEBUG ]]; then if [[ $DEBUG ]]; then
local progname="$progname[$$]" local progname="$progname[$$]" progname_prefix=1
fi fi
if [[ $DEBUG || $progname_prefix -gt 0 || if (( progname_prefix > 0 || ( progname_prefix < 0 && _lvl ) )); then
( $progname_prefix -le 0 && $_lvl -gt 0 ) ]]; then
nprefix="$progname: " nprefix="$progname: "
fi fi
printf "%s${color}%s:${reset} %s\n" "$nprefix" "$prefix" "$msg" printf "%s${color}%s:${reset} %s\n" "$nprefix" "$prefix" "$msg"
Expand All @@ -48,8 +47,7 @@ print_fmsg() {
if [[ -t 1 ]]; then if [[ -t 1 ]]; then
color="$fcolor" reset='\e[m' color="$fcolor" reset='\e[m'
fi fi
if [[ $progname_prefix -gt 0 || if (( progname_prefix > 0 || ( progname_prefix < 0 && _lvl ) )); then
( $progname_prefix -le 0 && $_lvl -gt 0 ) ]]; then
nprefix="$progname: " nprefix="$progname: "
fi fi
printf "%s${color}%s${reset} %s\n" "$nprefix" "$fprefix" "$msg" printf "%s${color}%s${reset} %s\n" "$nprefix" "$fprefix" "$msg"
Expand Down

0 comments on commit 13702cb

Please sign in to comment.