From 00fee78423de0e399f5705bb483e599e39b707c9 Mon Sep 17 00:00:00 2001 From: Edwin Kofler Date: Fri, 31 Mar 2023 20:22:24 -0700 Subject: [PATCH] fix!: Remove files containing only `asdf` wrapper functions (#1525) --- asdf.fish | 16 ++++++++++++++-- asdf.sh | 19 +++++++++++++++++-- lib/asdf.fish | 14 -------------- lib/asdf.sh | 20 -------------------- scripts/shellcheck.bash | 3 +-- scripts/shfmt.bash | 4 ---- 6 files changed, 32 insertions(+), 44 deletions(-) delete mode 100644 lib/asdf.fish delete mode 100644 lib/asdf.sh diff --git a/asdf.fish b/asdf.fish index 33abb95b..afb161dc 100644 --- a/asdf.fish +++ b/asdf.fish @@ -20,5 +20,17 @@ if not contains $_asdf_shims $fish_user_paths end set --erase _asdf_bin _asdf_shims -# Load the asdf wrapper function -. $ASDF_DIR/lib/asdf.fish +# The asdf function is a wrapper so we can export variables +function asdf + set command $argv[1] + set -e argv[1] + + switch "$command" + case shell + # Source commands that need to export variables. + command asdf export-shell-version fish $argv | source # asdf_allow: source + case '*' + # Forward other commands to asdf script. + command asdf "$command" $argv + end +end diff --git a/asdf.sh b/asdf.sh index cdbb1de8..a19265c0 100644 --- a/asdf.sh +++ b/asdf.sh @@ -70,6 +70,21 @@ esac unset -v _asdf_bin _asdf_shims -# shellcheck source=lib/asdf.sh -. "$ASDF_DIR/lib/asdf.sh" +# The asdf function is a wrapper so we can export variables +asdf() { + case $1 in + "shell") + if ! shift; then + printf '%s\n' 'asdf: Error: Failed to shift' >&2 + return 1 + fi + # Invoke command that needs to export variables. + eval "$(asdf export-shell-version sh "$@")" # asdf_allow: eval + ;; + *) + # Forward other commands to asdf script. + command asdf "$@" # asdf_allow: ' asdf ' + ;; + esac +} diff --git a/lib/asdf.fish b/lib/asdf.fish deleted file mode 100644 index f29b6076..00000000 --- a/lib/asdf.fish +++ /dev/null @@ -1,14 +0,0 @@ -# The asdf function is a wrapper so we can export variables -function asdf - set command $argv[1] - set -e argv[1] - - switch "$command" - case shell - # Source commands that need to export variables. - command asdf export-shell-version fish $argv | source # asdf_allow: source - case '*' - # Forward other commands to asdf script. - command asdf "$command" $argv - end -end diff --git a/lib/asdf.sh b/lib/asdf.sh deleted file mode 100644 index e5404aa8..00000000 --- a/lib/asdf.sh +++ /dev/null @@ -1,20 +0,0 @@ -# shellcheck shell=sh - -# The asdf function is a wrapper so we can export variables -asdf() { - case $1 in - "shell") - if ! shift; then - printf '%s\n' 'asdf: Error: Failed to shift' >&2 - return 1 - fi - - # Invoke command that needs to export variables. - eval "$(asdf export-shell-version sh "$@")" # asdf_allow: eval - ;; - *) - # Forward other commands to asdf script. - command asdf "$@" # asdf_allow: ' asdf ' - ;; - esac -} diff --git a/scripts/shellcheck.bash b/scripts/shellcheck.bash index ca49bd4c..7b56f745 100755 --- a/scripts/shellcheck.bash +++ b/scripts/shellcheck.bash @@ -4,8 +4,7 @@ set -euo pipefail # check .sh files shellcheck --shell sh --external-sources \ - asdf.sh \ - lib/*.sh + asdf.sh # check .bash files shellcheck --shell bash --external-sources \ diff --git a/scripts/shfmt.bash b/scripts/shfmt.bash index f9372d85..d42ae205 100755 --- a/scripts/shfmt.bash +++ b/scripts/shfmt.bash @@ -2,10 +2,6 @@ set -euo pipefail -# check .sh files -shfmt --language-dialect posix --indent 2 --diff \ - lib/*.sh - # check .bash files shfmt --language-dialect bash --indent 2 --diff \ completions/*.bash \