From 4db85bcf1f247f316ed5f849d37908db5fcfd314 Mon Sep 17 00:00:00 2001 From: Filippo Squillace Date: Sat, 18 Feb 2023 00:49:54 +0100 Subject: [PATCH] #318: Use multi-call wrapper --- lib/core/wrappers.sh | 24 +++++++++++++----------- tests/unit-tests/test-wrappers.sh | 2 +- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/lib/core/wrappers.sh b/lib/core/wrappers.sh index 7e8b3a8..1afbb2b 100644 --- a/lib/core/wrappers.sh +++ b/lib/core/wrappers.sh @@ -21,6 +21,17 @@ function create_wrappers() { local force=${1:-false} mkdir -p "${JUNEST_HOME}/usr/bin_wrappers" + # Arguments inside a variable (i.e. `JUNEST_ARGS`) separated by quotes + # are not recognized normally unless using `eval`. More info here: + # https://github.com/fsquillace/junest/issues/262 + # https://github.com/fsquillace/junest/pull/287 + cat < "${JUNEST_HOME}/usr/bin/junest_wrapper" +#!/usr/bin/env bash + +eval "junest_args_array=(\${JUNEST_ARGS:-ns})" +junest "\${junest_args_array[@]}" -- \$(basename \${0}) "\$@" +EOF + chmod +x "${JUNEST_HOME}/usr/bin/junest_wrapper" cd "${JUNEST_HOME}/usr/bin" || return 1 for file in * @@ -33,17 +44,8 @@ function create_wrappers() { then continue fi - # Arguments inside a variable (i.e. `JUNEST_ARGS`) separated by quotes - # are not recognized normally unless using `eval`. More info here: - # https://github.com/fsquillace/junest/issues/262 - # https://github.com/fsquillace/junest/pull/287 - cat < "${JUNEST_HOME}/usr/bin_wrappers/${file}" -#!/usr/bin/env bash - -eval "junest_args_array=(\${JUNEST_ARGS:-ns})" -junest "\${junest_args_array[@]}" -- ${file} "\$@" -EOF - chmod +x "${JUNEST_HOME}/usr/bin_wrappers/${file}" + rm -f "${JUNEST_HOME}/usr/bin_wrappers/$file" + ln -s "../bin/junest_wrapper" "${JUNEST_HOME}/usr/bin_wrappers/$file" done # Remove wrappers no longer needed diff --git a/tests/unit-tests/test-wrappers.sh b/tests/unit-tests/test-wrappers.sh index 8944ee5..c5a5857 100755 --- a/tests/unit-tests/test-wrappers.sh +++ b/tests/unit-tests/test-wrappers.sh @@ -81,7 +81,7 @@ function test_create_wrappers_verify_content(){ -b --bind /run /run2 -- -myfile +test-wrappers.sh pacman -Rsn neovim