Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

config/functions: fix bash-4.4 issue, and empty 2nd param behaviour #1896

Merged
merged 1 commit into from
Aug 21, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions config/functions
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ print_color() {
local clr_name="$1" clr_text="$2" clr_actual

if [ "$DISABLE_COLORS" == "yes" ]; then
[ -n "${clr_text}" ] && echo -en "${clr_text}"
[ $# -eq 2 ] && echo -en "${clr_text}"
return 0
fi

Expand All @@ -541,9 +541,9 @@ print_color() {
# Otherwise if $clr_name isn't defined, or doesn't exist, then use
# standard colours.
#
if [ -n "${clr_actual}" -a -z "${!clr_actual}" ]; then
if [[ -n "${clr_actual}" ]] && [[ -z "${!clr_actual}" ]]; then
clr_actual="${clr_name}"
elif [ -z "${clr_actual}" -o -z "${!clr_actual}" ]; then
elif [[ -z "${clr_actual}" ]] || [[ -z "${!clr_actual}" ]]; then
case "${clr_name}" in
CLR_ERROR) clr_actual="boldred";;
CLR_WARNING) clr_actual="boldred";;
Expand All @@ -567,7 +567,7 @@ print_color() {
esac
fi

if [ -n "${clr_text}" ]; then
if [ $# -eq 2 ]; then
echo -en "${!clr_actual}${clr_text}${endcolor}"
else
echo -en "${!clr_actual}"
Expand Down