fix: don't generate on error if backup file doesn't exists (#1057)

Signed-off-by: JrCs <90z7oey02@sneakemail.com>
This commit is contained in:
Yves Blusseau 2021-12-23 17:43:41 +01:00 committed by GitHub
parent 6bb07b6d36
commit 288468f93f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 3 deletions

View File

@ -70,7 +70,7 @@ write_shim_script() {
if [ -f "$shim_path" ]; then
if ! grep -x "# asdf-plugin: ${plugin_name} ${version}" "$shim_path" >/dev/null; then
sed -i.bak -e "s/exec /# asdf-plugin: ${plugin_name} ${version}\\"$'\n''exec /' "$shim_path"
rm "$shim_path".bak
rm -f "$shim_path".bak
fi
else
cat <<EOF >"$shim_path"

View File

@ -20,6 +20,6 @@ remove_shim_for_version() {
if ! grep "# asdf-plugin:" "$shim_path" >/dev/null ||
[ "$count_installed" -eq 0 ]; then
rm "$shim_path"
rm -f "$shim_path"
fi
}

View File

@ -60,7 +60,7 @@ version_command() {
if [ -f "$file" ] && grep "^$plugin_name " "$file" >/dev/null; then
sed -i.bak -e "s|^$plugin_name .*$|$plugin_name ${resolved_versions[*]}|" "$file"
rm "$file".bak
rm -f "$file".bak
else
printf "%s %s\\n" "$plugin_name" "${resolved_versions[*]}" >>"$file"
fi