From b8e94ca920f67f3bf5aa753197c473b1bb4570e0 Mon Sep 17 00:00:00 2001 From: champignoom <66909116+champignoom@users.noreply.github.com> Date: Fri, 18 Oct 2024 17:58:36 +0800 Subject: [PATCH] login: fix argument escaping --- proot-distro.sh | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/proot-distro.sh b/proot-distro.sh index 37fd0ac3c..900c7c646 100755 --- a/proot-distro.sh +++ b/proot-distro.sh @@ -1643,15 +1643,10 @@ command_login() { set -u done unset var - - local -a login_shell_args + if [ $# -ge 1 ]; then - # Wrap in quotes each argument to prevent word splitting. - local -a login_shell_args - for i in "$@"; do - login_shell_args+=("'$i'") - done - set -- "-c" "${login_shell_args[*]}" + # Escape each argument to prevent word splitting. + set -- "-c" "$(printf " %q" "$@")" else set -- fi