From 380173e619d78ae69a0959b6c5e93be7949a78b5 Mon Sep 17 00:00:00 2001 From: "Kyle J. McKay" Date: Sat, 3 Oct 2015 13:41:38 -0700 Subject: [PATCH] scripts: correct some non-portable issues Fix issues identified by Git's check-non-portable-shell.pl script. Signed-off-by: Kyle J. McKay --- bin/git-http-backend-verify | 3 ++- toolbox/edit-user-email.sh | 5 +++-- toolbox/remove-inactive-projects.sh | 4 ++-- toolbox/remove-user.sh | 3 ++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/bin/git-http-backend-verify b/bin/git-http-backend-verify index 989743e..41307bf 100755 --- a/bin/git-http-backend-verify +++ b/bin/git-http-backend-verify @@ -397,7 +397,8 @@ if ! "$cfg_basedir/bin/can_user_push_http" "$projbare" "$authuser"; then mv -f "$cfg_chroot/etc/sshactive/${authuser}," "$cfg_chroot/etc/sshactive/${authuser}" ! [ -e "$dir/.delaygc" ] || > "$dir/.allowgc" || : ) - export PATH_INFO="/$proj/mob/$suffix" + PATH_INFO="/$proj/mob/$suffix" + export PATH_INFO if [ -n "$GIT_HTTP_BACKEND_SHOW_ERRORS" ]; then exec "$cfg_git_http_backend_bin" "$@" else diff --git a/toolbox/edit-user-email.sh b/toolbox/edit-user-email.sh index 15306a2..6c7a105 100755 --- a/toolbox/edit-user-email.sh +++ b/toolbox/edit-user-email.sh @@ -22,13 +22,14 @@ if ! echo "$3" | grep -E -q '^[a-zA-Z0-9+._-]+@[a-zA-Z0-9.-]+$'; then echo "fatal: e-mail '$3' is not valid (^[a-zA-Z0-9+._-]+@[a-zA-Z0-9.-]+$)." exit 1 fi -sed -i.$$ \ +sed \ -e "s/^$1\(:[^:]*:[^:]*:[^:]*:\)$2\([,:]\)/$1\\1$3\\2/" \ -e "t show" \ -e "b" \ -e ": show" \ -e "w /dev/stderr" \ - "$ETC/passwd" + "$ETC/passwd" > "$ETC/passwd.$$" +mv -f "$ETC/passwd.$$" "$ETC/passwd" rm -f "$ETC/passwd.$$" if [ -n "$cfg_update_pwd_db" -a "$cfg_update_pwd_db" != "0" ]; then "$cfg_basedir/bin/update-pwd-db" "$ETC/passwd" "$1" diff --git a/toolbox/remove-inactive-projects.sh b/toolbox/remove-inactive-projects.sh index 273ee1b..6f7a7df 100755 --- a/toolbox/remove-inactive-projects.sh +++ b/toolbox/remove-inactive-projects.sh @@ -84,7 +84,7 @@ echo " done." exit #for i in $(find . -name heads -type d); do [ "$(ls $i)" ] && continue; mv ${i%/refs/heads} "$cfg_reporoot/_recyclebin/"; done -echo -n "Moving repositories to recycle bin..." +printf "Moving repositories to recycle bin..." while read x y; do f="${x%/*}" x="${x##*/}" @@ -95,7 +95,7 @@ while read x y; do done <$OUT echo " done." -echo -n "Deregistering projects..." +printf "Deregistering projects..." for i in `cut -d ' ' -f 1 $OUT`; do echo $i j=${i#./} diff --git a/toolbox/remove-user.sh b/toolbox/remove-user.sh index 7e2f0be..750c98e 100755 --- a/toolbox/remove-user.sh +++ b/toolbox/remove-user.sh @@ -23,7 +23,8 @@ if [ "$GRPS" ]; then echo "fatal: this simplistic script cannot remove users from groups." exit 1 fi -sed -i.$$ -e "/^$qu:/ d" "$ETC/passwd" +sed -e "/^$qu:/ d" "$ETC/passwd" > "$ETC/passwd.$$" +mv -f "$ETC/passwd.$$" "$ETC/passwd" || : rm -f "$ETC/passwd.$$" || : rm -f "$ETC/sshkeys/$u" || : rm -f "$ETC/sshcerts/$cfg_nickname"_"$u"_user_*.pem || : -- 2.11.4.GIT