From af09136b95486e41ebd458e5209fd53a3b308447 Mon Sep 17 00:00:00 2001 From: YISH Date: Wed, 27 Apr 2022 11:30:29 +0800 Subject: [PATCH] Fix `upgrade.sh` script error with `su -c` (#19483) * Fix scirpt err with `su -c`, add env auto loading. * Update upgrade.sh * Update upgrade.sh * Update contrib/upgrade.sh Co-authored-by: wxiaoguang Co-authored-by: wxiaoguang --- contrib/upgrade.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/contrib/upgrade.sh b/contrib/upgrade.sh index 9a5e903b6..3a98c277d 100755 --- a/contrib/upgrade.sh +++ b/contrib/upgrade.sh @@ -24,7 +24,8 @@ function giteacmd { if [[ $sudocmd = "su" ]]; then - "$sudocmd" - "$giteauser" -c "$giteabin" --config "$giteaconf" --work-path "$giteahome" "$@" + # `-c` only accept one string as argument. + "$sudocmd" - "$giteauser" -c "$(printf "%q " "$giteabin" "--config" "$giteaconf" "--work-path" "$giteahome" "$@")" else "$sudocmd" --user "$giteauser" "$giteabin" --config "$giteaconf" --work-path "$giteahome" "$@" fi