summaryrefslogtreecommitdiffstats
path: root/kickstart.sh
diff options
context:
space:
mode:
authorCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2017-05-28 20:29:16 +0300
committerCosta Tsaousis (ktsaou) <costa@tsaousis.gr>2017-05-28 20:29:16 +0300
commitd85af8a32f59430645cda4f1fe65bb082c38f9fa (patch)
treeb6bd3951af2411fac2fe522609775aa6769352bc /kickstart.sh
parent33850e34168c39932272402acd0cc8b1005740df (diff)
fix for printf %q on all scripts
Diffstat (limited to 'kickstart.sh')
-rwxr-xr-xkickstart.sh19
1 files changed, 16 insertions, 3 deletions
diff --git a/kickstart.sh b/kickstart.sh
index 94a50185e4..b022e56087 100755
--- a/kickstart.sh
+++ b/kickstart.sh
@@ -113,9 +113,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
@@ -127,11 +140,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"
"${@}"