diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-05-28 20:29:16 +0300 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-05-28 20:29:16 +0300 |
commit | d85af8a32f59430645cda4f1fe65bb082c38f9fa (patch) | |
tree | b6bd3951af2411fac2fe522609775aa6769352bc /installer | |
parent | 33850e34168c39932272402acd0cc8b1005740df (diff) |
fix for printf %q on all scripts
Diffstat (limited to 'installer')
-rw-r--r-- | installer/functions.sh | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/installer/functions.sh b/installer/functions.sh index 698993283f..3efeb45c66 100644 --- a/installer/functions.sh +++ b/installer/functions.sh @@ -142,9 +142,22 @@ run_failed() { printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n" } +ESCAPED_PRINT_METHOD= +printf "%q " test >/dev/null 2>&1 +[ $? -eq 0 ] && ESCAPED_PRINT_METHOD="printfq" +escaped_print() { + if [ "${ESCAPED_PRINT_METHOD}" = "printfq" ] + then + printf "%q " "${@}" + else + printf "%s" "${*}" + fi + return 0 +} + run_logfile="/dev/null" run() { - local user="${USER:-}" dir="${PWD}" info info_console + local user="${USER--}" dir="${PWD}" info info_console if [ "${UID}" = "0" ] then @@ -156,11 +169,11 @@ run() { fi printf >> "${run_logfile}" "${info}" - printf >> "${run_logfile}" "%q " "${@}" + escaped_print >> "${run_logfile}" "${@}" printf >> "${run_logfile}" " ... " printf >&2 "${info_console}${TPUT_BOLD}${TPUT_YELLOW}" - printf >&2 "%q " "${@}" + escaped_print >&2 "${@}" printf >&2 "${TPUT_RESET}\n" "${@}" |