From d0a4c0211839506efb7945e93715f622648da588 Mon Sep 17 00:00:00 2001 From: Peter Dave Hello Date: Mon, 2 Jul 2018 20:00:18 +0800 Subject: [PATCH] Improve upstart.tpl shell script syntax - Use spaces instead of tab for indent - Replace deprecated `command` with $(command) - Add missing quote to variable reference - Separate variable declaration and assign to avoid masking return values --- lib/templates/init-scripts/upstart.tpl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/templates/init-scripts/upstart.tpl b/lib/templates/init-scripts/upstart.tpl index 2bd728789..eba124bb3 100644 --- a/lib/templates/init-scripts/upstart.tpl +++ b/lib/templates/init-scripts/upstart.tpl @@ -24,7 +24,7 @@ MAX_OPEN_FILES= # overwrite settings from default file if [ -f "$DEFAULT" ]; then - . "$DEFAULT" + . "$DEFAULT" fi # set maximum open files if set @@ -33,7 +33,8 @@ if [ -n "$MAX_OPEN_FILES" ]; then fi get_user_shell() { - local shell=$(getent passwd ${1:-`whoami`} | cut -d: -f7 | sed -e 's/[[:space:]]*$//') + local shell + shell=$(getent passwd "${1:-$(whoami)}" | cut -d: -f7 | sed -e 's/[[:space:]]*$//') if [[ $shell == *"/sbin/nologin" ]] || [[ $shell == "/bin/false" ]] || [[ -z "$shell" ]]; then @@ -44,8 +45,9 @@ get_user_shell() { } super() { - local shell=$(get_user_shell $USER) - su - $USER -s $shell -c "PATH=$PATH; PM2_HOME=$PM2_HOME $*" + local shell + shell=$(get_user_shell $USER) + su - "$USER" -s "$shell" -c "PATH=$PATH; PM2_HOME=$PM2_HOME $*" } start() {