Merge pull request #863 from asdf-vm/ban-process-substitution

Ban process substitution from asdf codebase
This commit is contained in:
Trevor Brown 2021-05-20 08:44:58 -04:00 committed by GitHub
commit 156a82cc49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 23 additions and 5 deletions

View File

@ -11,9 +11,9 @@ plugin_update_command() {
if [ "$plugin_name" = "--all" ]; then
if [ -d "$(asdf_data_dir)"/plugins ]; then
while IFS= read -r dir; do
find "$(asdf_data_dir)"/plugins -mindepth 1 -maxdepth 1 -type d | while IFS= read -r dir; do
update_plugin "$(basename "$dir")" "$dir" "$gitref" &
done < <(find "$(asdf_data_dir)"/plugins -mindepth 1 -maxdepth 1 -type d)
done
wait
fi
else

View File

@ -119,7 +119,19 @@ remove_obsolete_shims() {
exec_names=$(plugin_executables "$plugin_name" "$full_version" | xargs -IX basename X | sort)
local obsolete_shims
obsolete_shims=$(comm -23 <(printf "%s\\n" "$shims") <(printf "%s\\n" "$exec_names"))
local formatted_shims
local formatted_exec_names
# comm only takes to files, so we write this data to temp files so we can
# pass it to comm.
formatted_shims=$(mktemp /tmp/asdf-command-reshim-formatted-shims.XXXXXX)
printf "%s\\n" "$shims" >"$formatted_shims"
formatted_exec_names=$(mktemp /tmp/asdf-command-reshim-formatted-exec-names.XXXXXX)
printf "%s\\n" "$exec_names" >"$formatted_exec_names"
obsolete_shims=$(comm -23 "$formatted_shims" "$formatted_exec_names")
rm -f "$formatted_exec_names" "$formatted_shims"
for shim_name in $obsolete_shims; do
remove_shim_for_version "$plugin_name" "$full_version" "$shim_name"

View File

@ -662,10 +662,14 @@ preset_versions() {
}
select_from_preset_version() {
shim_name=$1
local shim_name=$1
local shim_versions
local preset_versions
shim_versions=$(get_shim_versions "$shim_name")
if [ -n "$shim_versions" ]; then
preset_versions "$shim_name" | grep -F "$shim_versions" | head -n 1 | xargs -IVERSION printf "%s\\n" VERSION
preset_versions=$(preset_versions "$shim_name")
grep -f "$shim_versions" "$preset_versions" | head -n 1 | xargs -IVERSION printf "%s\\n" VERSION
fi
}

View File

@ -20,6 +20,8 @@ banned_commands=(
# echo isn't consistent across operating systems, and sometimes output can
# be confused with echo flags. printf does everything echo does and more.
echo
# Process substitution isn't POSIX compliant and cause trouble
"<("
)
setup() {