From b18d8aaacb1e2e5f14b4d3a9cc0de8100bc536bf Mon Sep 17 00:00:00 2001 From: Felipe Santos Date: Thu, 17 Jun 2021 13:01:39 -0300 Subject: [PATCH] Fix config command when using vscode (#926) --- src/main/bash/sdkman-config.sh | 6 +++--- src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy | 9 +++++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/main/bash/sdkman-config.sh b/src/main/bash/sdkman-config.sh index 12a79102..10af6eba 100644 --- a/src/main/bash/sdkman-config.sh +++ b/src/main/bash/sdkman-config.sh @@ -17,14 +17,14 @@ # function __sdk_config() { - local -r editor=${EDITOR:=vi} + local -r editor=(${EDITOR:=vi}) - if ! command -v "$editor" > /dev/null; then + if ! command -v "${editor[@]}" > /dev/null; then __sdkman_echo_red "No default editor configured." __sdkman_echo_yellow "Please set the default editor with the EDITOR environment variable." return 1 fi - "$editor" "${SDKMAN_DIR}/etc/config" + "${editor[@]}" "${SDKMAN_DIR}/etc/config" } \ No newline at end of file diff --git a/src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy b/src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy index 0f607db2..384c0a11 100644 --- a/src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy +++ b/src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy @@ -23,11 +23,15 @@ class ConfigCommandSpec extends SdkmanEnvSpecification { where: setupEnv << [ { - it.execute('nano() { echo "nano was called with $1"; }') + it.execute('nano() { echo "nano was called with $*"; }') it.execute("EDITOR=nano") }, { - it.execute('vi() { echo "vi was called with $1"; }') + it.execute('code() { echo "code was called with $*"; }') + it.execute("EDITOR='code --wait'") + }, + { + it.execute('vi() { echo "vi was called with $*"; }') it.execute("unset EDITOR") }, { @@ -36,6 +40,7 @@ class ConfigCommandSpec extends SdkmanEnvSpecification { ] verifyOutput << [ { output, baseDirectory -> output.contains("nano was called with ${baseDirectory}/.sdkman/etc/config") }, + { output, baseDirectory -> output.contains("code was called with --wait ${baseDirectory}/.sdkman/etc/config") }, { output, baseDirectory -> output.contains("vi was called with ${baseDirectory}/.sdkman/etc/config") }, { output, _ -> output.contains("No default editor configured.") } ]