Skip to content

Commit 82a69f0

Browse files
committed
enter: do not use a shell when executing a custom command, Fix #1275
Signed-off-by: Luca Di Maio <luca.dimaio1@gmail.com>
1 parent 50595a8 commit 82a69f0

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

Diff for: distrobox-enter

+2-6
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ fi
5858
container_command=""
5959
# by default we use getent to get the login shell of the user and use that
6060
container_command_login="/bin/sh -c \"\\\$(getent passwd ${USER} | cut -f 7 -d :) -l\""
61-
# and we execute container_command using sh -c
62-
container_command_prefix="/bin/sh -c"
6361
container_image_default="registry.fedoraproject.org/fedora-toolbox:39"
6462
container_manager="autodetect"
6563
container_manager_additional_flags=""
@@ -214,7 +212,7 @@ while :; do
214212
;;
215213
-e | --exec | --)
216214
shift
217-
container_command="$1"
215+
container_command="\"$1\""
218216
shift
219217
for arg in "$@"; do
220218
arg="$(echo "${arg}x" | sed 's|'\''|'\'\\\\\'\''|g')"
@@ -335,7 +333,6 @@ generate_command() {
335333
container_command_login="${container_command_login} --pty"
336334
fi
337335
container_command_login="${container_command_login} -c \"\\\$(getent passwd ${USER} | cut -f 7 -d :) -l\""
338-
container_command_prefix="${container_command_login} -c"
339336
else
340337
result_command="${result_command}
341338
--user=\"${USER}"\"
@@ -468,8 +465,7 @@ generate_command() {
468465
${container_name}"
469466

470467
if [ -n "${container_command}" ]; then
471-
result_command="${result_command}
472-
${container_command_prefix} \"${container_command}\""
468+
result_command="${result_command} ${container_command}"
473469
else
474470
# if no command was specified, let's execute a command that will find
475471
# and run the default shell for the user

0 commit comments

Comments
 (0)