mirror of
https://github.com/asdf-vm/asdf.git
synced 2024-11-15 01:28:17 -07:00
fix: no longer write temporary files to home directory (#1592)
This commit is contained in:
parent
299dc97a5b
commit
624604a862
@ -61,8 +61,15 @@ version_command() {
|
||||
done
|
||||
|
||||
if [ -f "$file" ] && grep "^$plugin_name " "$file" >/dev/null; then
|
||||
sed -i.bak -e "s|^$plugin_name .*$|$plugin_name ${resolved_versions[*]}|" "$file"
|
||||
rm -f "$file".bak
|
||||
local temp_dir
|
||||
temp_dir=${TMPDIR:-/tmp}
|
||||
|
||||
local temp_tool_versions_file
|
||||
temp_tool_versions_file=$(mktemp "$temp_dir/asdf-tool-versions-file.XXXXXX")
|
||||
|
||||
cp -f "$file" "$temp_tool_versions_file"
|
||||
sed -e "s|^$plugin_name .*$|$plugin_name ${resolved_versions[*]}|" "$temp_tool_versions_file" >"$file"
|
||||
rm -f "$temp_tool_versions_file"
|
||||
else
|
||||
# Add a trailing newline at the end of the file if missing
|
||||
[[ -f "$file" && -n "$(tail -c1 "$file")" ]] && printf '\n' >>"$file"
|
||||
|
Loading…
Reference in New Issue
Block a user