From 8084b58778f822862286af88c4015cecf36dabe4 Mon Sep 17 00:00:00 2001 From: 89luca89 Date: Mon, 6 Dec 2021 08:43:55 +0100 Subject: [PATCH] create, enter: use eval to execute the generated command, remove shellcheck exception SC2091 --- .github/workflows/main.yml | 2 +- distrobox-create | 7 ++++--- distrobox-enter | 5 +++-- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1357fba580..2fb6e1931e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -30,7 +30,7 @@ jobs: # uses: luizm/action-sh-checker@7f44869033b40ee4ffe7dc76c87a1bc66e3d025a uses: luizm/action-sh-checker@v0.3.0 env: - SHELLCHECK_OPTS: -o all -Cnever -Sstyle -a -f gcc -x -e SC2091 + SHELLCHECK_OPTS: -o all -Cnever -Sstyle -a -f gcc -x SHFMT_OPTS: -s # arguments to shfmt. with: sh_checker_comment: false diff --git a/distrobox-create b/distrobox-create index 8b8ac7248f..25e3fbc65d 100755 --- a/distrobox-create +++ b/distrobox-create @@ -114,7 +114,7 @@ generate_command() { echo "--log-level debug" fi echo "--dns none - --env XDG_RUNTIME_DIR=/run/user/${container_user_uid} + --env=\"XDG_RUNTIME_DIR=/run/user/${container_user_uid}\" --hostname ${container_name} --ipc host" # if [ -f /dev/pts ]; then @@ -126,7 +126,7 @@ generate_command() { # # also mount the distrobox-init utility as the container entrypoint echo "--name ${container_name} - --env=SHELL=${SHELL} + --env=\"SHELL=${SHELL}\" --network host --no-hosts --pid host @@ -189,4 +189,5 @@ if ! podman image exists "${container_image}"; then fi # Generate the command and execute -$(generate_command) +# shellcheck disable=SC2046 +eval $(generate_command) diff --git a/distrobox-enter b/distrobox-enter index 4162126e03..1c8f9c06da 100755 --- a/distrobox-enter +++ b/distrobox-enter @@ -127,11 +127,12 @@ generate_command() { echo "--env=DISTROBOX_ENTER_PATH=$(command -v distrobox-enter)" # exporting current environment to container for i in $(printenv); do - echo "--env=${i}" + echo "--env=\"${i}\"" done # run selected pod with command+args echo "${container_name} ${container_command}" } # Generate the command and execute -$(generate_command) +# shellcheck disable=SC2046 +eval $(generate_command)