work around %q not being supported in busybox
Costa Tsaousis (ktsaou) committed
May 28, 2017 at 20:22 UTC
33850e34168c39932272402acd0cc8b1005740df
1 file changed
+15
-2
kickstart-static64.sh
+15
-2
@@ -94,6 +94,19 @@ run_failed() {
94
printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n"
95
}
96
97
+ESCAPED_PRINT_METHOD=
98
+printf "%q " test >/dev/null 2>&1
99
+[ $? -eq 0 ] && ESCAPED_PRINT_METHOD="printfq"
100
+escaped_print() {
101
+ if [ "${ESCAPED_PRINT_METHOD}" = "printfq" ]
102
+ then
103
+ printf "%q " "${@}"
104
+ else
105
+ printf "%s" "${*}"
106
+ fi
107
+ return 0
108
+}
109
+
110
run_logfile="/dev/null"
111
run() {
112
local user="${USER:-}" dir="${PWD}" info info_console
@@ -108,11 +121,11 @@ run() {
121
fi
122
123
printf >> "${run_logfile}" "${info}"
111
- printf >> "${run_logfile}" "%q " "${@}"
124
+ escaped_print >> "${run_logfile}" "${@}"
125
printf >> "${run_logfile}" " ... "
126
127
printf >&2 "${info_console}${TPUT_BOLD}${TPUT_YELLOW}"
115
- printf >&2 "%q " "${@}"
128
+ escaped_print >&2 "${@}"
129
printf >&2 "${TPUT_RESET}\n"
130
131
"${@}"