summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/librefetch/librefetch-install.in16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/librefetch/librefetch-install.in b/src/librefetch/librefetch-install.in
index 13ac876..1a18757 100644
--- a/src/librefetch/librefetch-install.in
+++ b/src/librefetch/librefetch-install.in
@@ -20,6 +20,7 @@
# You should have received a copy of the GNU General Public License
# along with Parabola. If not, see <http://www.gnu.org/licenses/>.
+set -ueE
. "$(librelib messages)"
# This line should be installed
@@ -57,14 +58,15 @@ post_install() {
msg2 "%s: librefetch is already in %q" "${0##*/}" "$(realpath -s "$file")"
local line del=false
for line in "${old_code[@]}"; do
- if has_line "$line"; then
- pre_remove
- post_install
+ if has_line "$file" "$line"; then
+ msg2 "%s: ... but it's an old version" "${0##*/}"
+ pre_remove "$file"
+ post_install "$file"
return $?
fi
done
else
- msg2 "%s: adding librefetch to %1" "${0##*/}" "$(realpath -s "$file")"
+ msg2 "%s: adding librefetch to %q" "${0##*/}" "$(realpath -s "$file")"
printf '%s\n' "$new_code" >> "$file"
fi
}
@@ -75,14 +77,14 @@ pre_remove() {
msg2 "%s: removing librefetch from %q" "${0##*/}" "$(realpath -s "$file")"
# Check for the old stuff
- sed -ri 's/^#(.* )# commented out by the libretools post_install script/\1/' "$file"
+ sed -ri 's/^#(.*) # commented out by the libretools post_install script/\1/' "$file"
local line
for line in "${old_code[@]}"; do
- del_line "$line"
+ del_line "$file" "$line"
done
# Check for the current stuff
- del_line "$new_code"
+ del_line "$file" "$new_code"
}
usage() {