mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
Add .bash file extensions to files containing code executed by Bash
This commit is contained in:
parent
51104c9cea
commit
52cbf1165c
16
bin/asdf
16
bin/asdf
@ -1,7 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# shellcheck source=lib/utils.sh
|
||||
source "$(dirname "$(dirname "$0")")/lib/utils.sh"
|
||||
# shellcheck source=lib/utils.bash
|
||||
source "$(dirname "$(dirname "$0")")/lib/utils.bash"
|
||||
|
||||
find_cmd() {
|
||||
local cmd_dir="$1"
|
||||
@ -9,10 +9,10 @@ find_cmd() {
|
||||
|
||||
local cmd_name
|
||||
local args_offset="$#"
|
||||
cmd_name="command-$(echo "${@:1:${args_offset}}" | tr ' ' '-')"
|
||||
cmd_name="command-$(echo "${@:1:${args_offset}}" | tr ' ' '-').bash"
|
||||
while [ ! -f "$cmd_dir/$cmd_name" ] && [ "$args_offset" -gt 0 ]; do
|
||||
args_offset=$((args_offset - 1))
|
||||
cmd_name="command-$(echo "${@:1:${args_offset}}" | tr ' ' '-')"
|
||||
cmd_name="command-$(echo "${@:1:${args_offset}}" | tr ' ' '-').bash"
|
||||
done
|
||||
|
||||
if [ -f "$cmd_dir/$cmd_name" ]; then
|
||||
@ -29,15 +29,15 @@ find_asdf_cmd() {
|
||||
'exec' | 'current' | 'env' | 'global' | 'install' | 'latest' | 'local' | \
|
||||
'reshim' | 'uninstall' | 'update' | 'where' | 'which' | \
|
||||
'export-shell-version')
|
||||
echo "$asdf_cmd_dir/command-$1" 2
|
||||
echo "$asdf_cmd_dir/command-$1.bash" 2
|
||||
;;
|
||||
|
||||
'' | '--help' | '-h' | 'help')
|
||||
echo "$asdf_cmd_dir/command-help" 2
|
||||
echo "$asdf_cmd_dir/command-help.bash" 2
|
||||
;;
|
||||
|
||||
'--version' | 'version')
|
||||
echo "$asdf_cmd_dir/command-version" 2
|
||||
echo "$asdf_cmd_dir/command-version.bash" 2
|
||||
;;
|
||||
|
||||
*)
|
||||
@ -79,7 +79,7 @@ asdf_cmd() {
|
||||
local asdf_cmd_dir
|
||||
asdf_cmd_dir="$(asdf_dir)/lib/commands"
|
||||
echo "Unknown command: \`asdf ${*}\`" >&2
|
||||
source "$asdf_cmd_dir/command-help" >&2
|
||||
source "$asdf_cmd_dir/command-help.bash" >&2
|
||||
return 127
|
||||
fi
|
||||
}
|
||||
|
@ -4,8 +4,8 @@
|
||||
echo "asdf is self upgrading shims to new asdf exec ..."
|
||||
|
||||
asdf_dir="$(dirname "$(dirname "$(dirname "$0")")")"
|
||||
# shellcheck source=lib/utils.sh
|
||||
source "$asdf_dir/lib/utils.sh"
|
||||
# shellcheck source=lib/utils.bash
|
||||
source "$asdf_dir/lib/utils.bash"
|
||||
rm "$(asdf_data_dir)"/shims/*
|
||||
"$asdf_dir"/bin/asdf reshim
|
||||
shim_name=$(basename "$2")
|
||||
|
@ -35,7 +35,7 @@ This script should install the version, in the path mentioned in `ASDF_INSTALL_P
|
||||
|
||||
The install script should exit with a status of `0` when the installation is successful. If the installation fails the script should exit with any non-zero exit status.
|
||||
|
||||
If possible the script should only place files in the `ASDF_INSTALL_PATH` directory once the build and installation of the tool is deemed successful by the install script. asdf [checks for the existence](https://github.com/asdf-vm/asdf/blob/242d132afbf710fe3c7ec23c68cec7bdd2c78ab5/lib/utils.sh#L44) of the `ASDF_INSTALL_PATH` directory in order to determine if that version of the tool is installed. If the `ASDF_INSTALL_PATH` directory is populated at the beginning of the installation process other asdf commands run in other terminals during the installation may consider that version of the tool installed, even when it is not fully installed.
|
||||
If possible the script should only place files in the `ASDF_INSTALL_PATH` directory once the build and installation of the tool is deemed successful by the install script. asdf [checks for the existence](https://github.com/asdf-vm/asdf/blob/242d132afbf710fe3c7ec23c68cec7bdd2c78ab5/lib/utils.bash#L44) of the `ASDF_INSTALL_PATH` directory in order to determine if that version of the tool is installed. If the `ASDF_INSTALL_PATH` directory is populated at the beginning of the installation process other asdf commands run in other terminals during the installation may consider that version of the tool installed, even when it is not fully installed.
|
||||
|
||||
## Optional Scripts
|
||||
|
||||
@ -118,7 +118,7 @@ Plugin authors can use this feature to provide utilities related to their tools,
|
||||
or even create plugins that are just new command extensions for asdf itself.
|
||||
|
||||
When `command*` files exists but have no executable bit set, they are considered to be
|
||||
bash scripts and will be sourced having all the functions from `$ASDF_DIR/lib/utils.sh`
|
||||
bash scripts and will be sourced having all the functions from `$ASDF_DIR/lib/utils.bash`
|
||||
available. Also, the `$ASDF_CMD_FILE` resolves to the full path of the file being sourced.
|
||||
If the executable bit is set, they are just executed and replace the asdf execution.
|
||||
|
||||
|
@ -1,5 +0,0 @@
|
||||
# -*- sh -*-
|
||||
|
||||
# shellcheck source=lib/commands/version_commands.sh
|
||||
source "$(dirname "$ASDF_CMD_FILE")/version_commands.sh"
|
||||
version_command global "$@"
|
5
lib/commands/command-global.bash
Normal file
5
lib/commands/command-global.bash
Normal file
@ -0,0 +1,5 @@
|
||||
# -*- sh -*-
|
||||
|
||||
# shellcheck source=lib/commands/version_commands.bash
|
||||
source "$(dirname "$ASDF_CMD_FILE")/version_commands.bash"
|
||||
version_command global "$@"
|
@ -1,7 +1,7 @@
|
||||
# -*- sh -*-
|
||||
|
||||
# shellcheck source=lib/commands/version_commands.sh
|
||||
source "$(dirname "$ASDF_CMD_FILE")/version_commands.sh"
|
||||
# shellcheck source=lib/commands/version_commands.bash
|
||||
source "$(dirname "$ASDF_CMD_FILE")/version_commands.bash"
|
||||
|
||||
local_command() {
|
||||
local parent=false
|
@ -1,7 +1,7 @@
|
||||
# -*- sh -*-
|
||||
|
||||
# shellcheck source=lib/commands/reshim.sh
|
||||
source "$(dirname "$ASDF_CMD_FILE")/reshim.sh"
|
||||
# shellcheck source=lib/commands/reshim.bash
|
||||
source "$(dirname "$ASDF_CMD_FILE")/reshim.bash"
|
||||
|
||||
reshim_command() {
|
||||
local plugin_name=$1
|
@ -1,7 +1,7 @@
|
||||
# -*- sh -*-
|
||||
|
||||
# shellcheck source=lib/commands/reshim.sh
|
||||
source "$(dirname "$ASDF_CMD_FILE")/reshim.sh"
|
||||
# shellcheck source=lib/commands/reshim.bash
|
||||
source "$(dirname "$ASDF_CMD_FILE")/reshim.bash"
|
||||
|
||||
uninstall_command() {
|
||||
local plugin_name=$1
|
@ -630,7 +630,7 @@ get_shim_versions() {
|
||||
|
||||
preset_versions() {
|
||||
shim_name=$1
|
||||
shim_plugin_versions "${shim_name}" | cut -d' ' -f 1 | uniq | xargs -IPLUGIN bash -c "source $(asdf_dir)/lib/utils.sh; echo PLUGIN \$(get_preset_version_for PLUGIN)"
|
||||
shim_plugin_versions "${shim_name}" | cut -d' ' -f 1 | uniq | xargs -IPLUGIN bash -c "source $(asdf_dir)/lib/utils.bash; echo PLUGIN \$(get_preset_version_for PLUGIN)"
|
||||
}
|
||||
|
||||
select_from_preset_version() {
|
2
lint.sh
2
lint.sh
@ -2,7 +2,7 @@
|
||||
exec shellcheck -s bash -x \
|
||||
asdf.sh lint.sh release/tag.sh \
|
||||
bin/asdf bin/private/asdf-exec \
|
||||
lib/utils.sh lib/commands/* \
|
||||
lib/utils.bash lib/commands/*.bash \
|
||||
completions/*.bash \
|
||||
test/test_helpers.bash \
|
||||
test/fixtures/dummy_plugin/bin/*
|
||||
|
@ -4,8 +4,8 @@
|
||||
# tests fail when it is set to something other than the temp dir.
|
||||
unset ASDF_DIR
|
||||
|
||||
# shellcheck source=lib/utils.sh
|
||||
. "$(dirname "$BATS_TEST_DIRNAME")"/lib/utils.sh
|
||||
# shellcheck source=lib/utils.bash
|
||||
. "$(dirname "$BATS_TEST_DIRNAME")"/lib/utils.bash
|
||||
|
||||
setup_asdf_dir() {
|
||||
BASE_DIR=$(mktemp -dt asdf.XXXX)
|
||||
|
Loading…
Reference in New Issue
Block a user