From bd9e8f3d19098563f4798553176d3e3ab9b50b04 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 4 Jan 2015 15:12:16 -0500 Subject: librefetch-install: fix --- src/librefetch/librefetch-install.in | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/librefetch') 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 . +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() { -- cgit v1.2.2