diff --git a/lib/bash/io.sh b/lib/bash/io.sh index 8d64774..5004703 100644 --- a/lib/bash/io.sh +++ b/lib/bash/io.sh @@ -1,64 +1,66 @@ #!/bin/bash function color_echo() { - echo -e "$@" + color_echo_n $@ + echo } function color_echo_n() { - echo -en "$@" + echo -e -n $@ + #while [ $# -gt 0 ]; do printf "%b" $1; echo -n " "; shift; done } function debug_echo() { color_echo "${White}DEBUG:${NoColor} $@" } function warning_echo() { color_echo "${Yellow}WARNING:${NoColor} $@" 1>&2 } function error_echo() { color_echo "${Red}ERROR:${NoColor} $@" 1>&2 } function info_echo() { color_echo "${Green}INFO:${NoColor} $@" } function OK_echo() { color_echo "${Green}OK${NoColor}" } function KO_echo() { color_echo "${Red}KO${NoColor}" } function check_rc_echo { if [ $1 -eq 0 ]; then OK_echo; return 0; else KO_echo; return 1; fi } function confirm() { function_exists get_parameter if [ $? -eq 0 ]; then forced=$(get_parameter 'force'); if [ "$forced" == "set" ]; then return 1 fi fi color_echo "${White}Confirmation requested:${NoColor}" color_echo "$@" color_echo_n "Press ${Green}Y${NoColor}(es) to confirm or ${Red}ENTER${NoColor} to cancel. >>> " local ans read ans case $ans in Y|y|Yes|YES|yes) color_echo "${Green}Confirmed.${NoColor}" return 1 break;; *) color_echo "${Red}Cancelled.${NoColor}" return 0 break;; esac } # EOF