Browse code

Quote error messages

As a follow-on to I28aebffce6c5561360a9e44c1abc44b709054c30; make sure
we quote the error messages on the way through so they retain their
newlines.

Change-Id: I493317948264941b4788b100a0b0bc13d2698acf

Ian Wienand authored on 2018/10/08 13:20:34
Showing 1 changed files
... ...
@@ -228,9 +228,9 @@ function err {
228 228
     xtrace=$(set +o | grep xtrace)
229 229
     set +o xtrace
230 230
     local msg="[ERROR] ${BASH_SOURCE[2]}:$1 $2"
231
-    echo $msg 1>&2;
231
+    echo "$msg" 1>&2;
232 232
     if [[ -n ${LOGDIR} ]]; then
233
-        echo $msg >> "${LOGDIR}/error.log"
233
+        echo "$msg" >> "${LOGDIR}/error.log"
234 234
     fi
235 235
     $xtrace
236 236
     return $exitcode
... ...
@@ -283,7 +283,7 @@ function warn {
283 283
     xtrace=$(set +o | grep xtrace)
284 284
     set +o xtrace
285 285
     local msg="[WARNING] ${BASH_SOURCE[2]}:$1 $2"
286
-    echo $msg
286
+    echo "$msg"
287 287
     $xtrace
288 288
     return $exitcode
289 289
 }
... ...
@@ -1442,11 +1442,11 @@ function _common_systemd_pitfalls {
1442 1442
         read -r -d '' msg << EOF || true  # read returns 1 for EOF, but it is ok here
1443 1443
 You are trying to use run_process with sudo, this is not going to work under systemd.
1444 1444
 
1445
-If you need to run a service as a user other than $STACK_USER call it with:
1445
+If you need to run a service as a user other than \$STACK_USER call it with:
1446 1446
 
1447 1447
    run_process \$name \$cmd \$group \$user
1448 1448
 EOF
1449
-        die $LINENO $msg
1449
+        die $LINENO "$msg"
1450 1450
     fi
1451 1451
 
1452 1452
     if [[ ! "$cmd" =~ ^/ ]]; then
... ...
@@ -1456,7 +1456,7 @@ start under systemd.
1456 1456
 
1457 1457
 Please update your run_process stanza to have an absolute path.
1458 1458
 EOF
1459
-        die $LINENO $msg
1459
+        die $LINENO "$msg"
1460 1460
     fi
1461 1461
 
1462 1462
 }