diff options
author | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-05-28 20:22:46 +0300 |
---|---|---|
committer | Costa Tsaousis (ktsaou) <costa@tsaousis.gr> | 2017-05-28 20:22:46 +0300 |
commit | 33850e34168c39932272402acd0cc8b1005740df (patch) | |
tree | 5a32811b23c8698cd25bbaf312e0c747bc0e3c13 /kickstart-static64.sh | |
parent | cf57a8960ff8b3c53093ab0859721bc2cdb1300e (diff) |
work around %q not being supported in busybox
Diffstat (limited to 'kickstart-static64.sh')
-rwxr-xr-x | kickstart-static64.sh | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/kickstart-static64.sh b/kickstart-static64.sh index d85d5128d1..963161a601 100755 --- a/kickstart-static64.sh +++ b/kickstart-static64.sh @@ -94,6 +94,19 @@ 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 @@ -108,11 +121,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" "${@}" |