Tell sed to create backup files, and the remove them

This seems like the easiest way forward, considering the incompatability between the LInux and MacOS versions of sed.
This commit is contained in:
William Ashton 2017-10-27 10:27:27 -04:00
parent dc3865c9fd
commit 43fd8c978d
2 changed files with 6 additions and 3 deletions

View File

@ -58,7 +58,8 @@ write_shim_script() {
cp "$plugin_shims_path/$executable_name" "$shim_path"
elif [ -f "$shim_path" ]; then
if ! grep "# asdf-plugin-version: $version" "$shim_path" > /dev/null; then
sed -i '' -e "s/\(asdf-plugin: $plugin_name\)/\1\\"$'\n'"# asdf-plugin-version: $version/" "$shim_path"
sed -i.bak -e "s/\(asdf-plugin: $plugin_name\)/\1\\"$'\n'"# asdf-plugin-version: $version/" "$shim_path"
rm "$shim_path".bak
fi
else
cat <<EOF > "$shim_path"
@ -210,7 +211,8 @@ remove_shim_for_version() {
return 0
fi
sed -i '' -e "/# asdf-plugin-version: $version/d" "$shim_path"
sed -i.bak -e "/# asdf-plugin-version: $version/d" "$shim_path"
rm "$shim_path".bak
if [ ! -f "$plugin_shims_path/$executable_name" ] && \
! grep "# asdf-plugin-version" "$shim_path" > /dev/null || \

View File

@ -25,7 +25,8 @@ version_command() {
done
if [ -f "$file" ] && grep "$plugin" "$file" > /dev/null; then
sed -i '' -e "s/$plugin .*/$plugin ${versions[*]}/" "$file"
sed -i.bak -e "s/$plugin .*/$plugin ${versions[*]}/" "$file"
rm "$file".bak
else
echo "$plugin ${versions[*]}" >> "$file"
fi