fix for printf %q on all scripts
Costa Tsaousis (ktsaou) committed
May 28, 2017 at 20:29 UTC
d85af8a32f59430645cda4f1fe65bb082c38f9fa
3 files changed
+33
-7
installer/functions.sh
+16
-3
@@ -142,9 +142,22 @@ run_failed() {
142
printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n"
143
}
144
145
+ESCAPED_PRINT_METHOD=
146
+printf "%q " test >/dev/null 2>&1
147
+[ $? -eq 0 ] && ESCAPED_PRINT_METHOD="printfq"
148
+escaped_print() {
149
+ if [ "${ESCAPED_PRINT_METHOD}" = "printfq" ]
150
+ then
151
+ printf "%q " "${@}"
152
+ else
153
+ printf "%s" "${*}"
154
+ fi
155
+ return 0
156
+}
157
+
158
run_logfile="/dev/null"
159
run() {
147
- local user="${USER:-}" dir="${PWD}" info info_console
160
+ local user="${USER--}" dir="${PWD}" info info_console
161
162
if [ "${UID}" = "0" ]
163
then
@@ -156,11 +169,11 @@ run() {
169
fi
170
171
printf >> "${run_logfile}" "${info}"
159
- printf >> "${run_logfile}" "%q " "${@}"
172
+ escaped_print >> "${run_logfile}" "${@}"
173
printf >> "${run_logfile}" " ... "
174
175
printf >&2 "${info_console}${TPUT_BOLD}${TPUT_YELLOW}"
163
- printf >&2 "%q " "${@}"
176
+ escaped_print >&2 "${@}"
177
printf >&2 "${TPUT_RESET}\n"
178
179
"${@}"
kickstart-static64.sh
+1
-1
@@ -109,7 +109,7 @@ escaped_print() {
109
110
run_logfile="/dev/null"
111
run() {
112
- local user="${USER:-}" dir="${PWD}" info info_console
112
+ local user="${USER--}" dir="${PWD}" info info_console
113
114
if [ "${UID}" = "0" ]
115
then
kickstart.sh
+16
-3
@@ -113,9 +113,22 @@ run_failed() {
113
printf >&2 "${TPUT_BGRED}${TPUT_WHITE}${TPUT_BOLD} FAILED ${TPUT_RESET} ${*} \n\n"
114
}
115
116
+ESCAPED_PRINT_METHOD=
117
+printf "%q " test >/dev/null 2>&1
118
+[ $? -eq 0 ] && ESCAPED_PRINT_METHOD="printfq"
119
+escaped_print() {
120
+ if [ "${ESCAPED_PRINT_METHOD}" = "printfq" ]
121
+ then
122
+ printf "%q " "${@}"
123
+ else
124
+ printf "%s" "${*}"
125
+ fi
126
+ return 0
127
+}
128
+
129
run_logfile="/dev/null"
130
run() {
118
- local user="${USER:-}" dir="${PWD}" info info_console
131
+ local user="${USER--}" dir="${PWD}" info info_console
132
133
if [ "${UID}" = "0" ]
134
then
@@ -127,11 +140,11 @@ run() {
140
fi
141
142
printf >> "${run_logfile}" "${info}"
130
- printf >> "${run_logfile}" "%q " "${@}"
143
+ escaped_print >> "${run_logfile}" "${@}"
144
printf >> "${run_logfile}" " ... "
145
146
printf >&2 "${info_console}${TPUT_BOLD}${TPUT_YELLOW}"
134
- printf >&2 "%q " "${@}"
147
+ escaped_print >&2 "${@}"
148
printf >&2 "${TPUT_RESET}\n"
149
150
"${@}"