From e75d94cfa99c8fc98ee6c565b7bf9b9aee99da81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Sun, 18 Oct 2020 23:21:24 +0200 Subject: [PATCH 1/3] simplify ${#@} to $# In bash both are identical, in POSIX sh however ${#@} yields the string length of $@. So after set 3 4 5 $@ expands to 5 in (e.g.) dash. --- bin/sys | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/sys b/bin/sys index de24861..2a50195 100755 --- a/bin/sys +++ b/bin/sys @@ -5,7 +5,7 @@ function startsWithDash { test "${1:0:1}" = "-" } function paramsAreEmpty { - test ${#@} -eq 0 + test $# -eq 0 } function printHelp { From 4ab5ddec80576d95bce1a1add26fc9b93f83203d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Sun, 18 Oct 2020 23:25:15 +0200 Subject: [PATCH 2/3] Quote path names This is relevant if the homedir of a user or SYSGIT_PATH_OFFSET contain spaces. --- bin/sys | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bin/sys b/bin/sys index 2a50195..a9fab4b 100755 --- a/bin/sys +++ b/bin/sys @@ -57,10 +57,10 @@ if [ -n "$SUDO_USER" ]; then # check for user credentials! if [ -z "$GIT_COMMITTER_NAME" ]; then # if they do not exist, try to read from gitconfig in home dir - export GIT_COMMITTER_NAME=$(git config -f $git_config_file user.name) - export GIT_AUTHOR_NAME=$(git config -f $git_config_file user.name) - export GIT_COMMITTER_EMAIL=$(git config -f $git_config_file user.email) - export GIT_AUTHOR_EMAIL=$(git config -f $git_config_file user.email) + export GIT_COMMITTER_NAME=$(git config -f "$git_config_file" user.name) + export GIT_AUTHOR_NAME=$(git config -f "$git_config_file" user.name) + export GIT_COMMITTER_EMAIL=$(git config -f "$git_config_file" user.email) + export GIT_AUTHOR_EMAIL=$(git config -f "$git_config_file" user.email) # if this fails ... generate the credentials fi : ${GIT_COMMITTER_EMAIL:=${SUDO_USER}@${hostname}} @@ -69,7 +69,7 @@ if [ -n "$SUDO_USER" ]; then : ${GIT_AUTHOR_NAME:=${SUDO_USER}} fi ################################################################################ -export GIT_DIR=$SYSGIT_PATH_OFFSET/var/lib/sysgit +export GIT_DIR="$SYSGIT_PATH_OFFSET/var/lib/sysgit" test -e /var/lib/sysgit/ssh && export GIT_SSH=/var/lib/sysgit/ssh "$@" From afaebe9df19978f0f6681025b467dbd71c96b3e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Sun, 18 Oct 2020 23:25:36 +0200 Subject: [PATCH 3/3] Don't quote : : isn't special, so there is no need to quote it. --- bin/sys | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/sys b/bin/sys index a9fab4b..4a0d2c4 100755 --- a/bin/sys +++ b/bin/sys @@ -51,7 +51,7 @@ fi ### create/find credentials for using with git if [ -n "$SUDO_USER" ]; then - homedir=$(getent passwd ${SUDO_USER} | cut -d\: -f 6) + homedir=$(getent passwd ${SUDO_USER} | cut -d: -f 6) git_config_file="${homedir}"/.gitconfig hostname=$(hostname -f) # check for user credentials!