aboutsummaryrefslogtreecommitdiff
path: root/kiss
diff options
context:
space:
mode:
authordylan.araps@gmail.com <dylan.araps@gmail.com>2020-01-28 19:27:17 +0000
committerdylan.araps@gmail.com <dylan.araps@gmail.com>2020-01-28 19:27:17 +0000
commit328a9067418ff611a0b9fd68db56e91c3b48eddb (patch)
tree10ca39093aa1dff429421184e3ce0641f109036c /kiss
parent8e29ac652f4ceef31a4ac3922f404d7c7878c737 (diff)
downloadcpt-328a9067418ff611a0b9fd68db56e91c3b48eddb.tar.gz
kiss: revert
FossilOrigin-Name: 0260f498582bbca92f5a53d0d6beb48fbedd1a264ef902a6fef6e43a09e2cb96
Diffstat (limited to 'kiss')
-rwxr-xr-xkiss31
1 files changed, 11 insertions, 20 deletions
diff --git a/kiss b/kiss
index e6936f1..24098e0 100755
--- a/kiss
+++ b/kiss
@@ -148,24 +148,12 @@ dosu() {
fi
}
-ssed() {
- # Simple wrapper around 'sed' to handle in-place
- # replacements in a portable way.
-
+regex_escape() {
# Escape all required characters in both the search and
# replace portions of two strings for use in a 'sed' call
# as "plain-text".
sea=$(echo "$1" | sed 's/[]\/$*.^[]/\\&/g')
rep=$(echo "$2" | sed 's/[\/&]/\\&/g')
-
- # Save the replacement result to a temporary file and then
- # overwrite the original file with it.
- #
- # The '$4' equates to a 'sudo'/'su' equivalent when parts
- # of the function's body must run as 'root'. Globbing is
- # disabled and the input hardcoded so this is fine.
- $4 sed "s/$sea/$rep/" "$3" > "$3.bak"
- $4 mv -f "$3.bak" "$3"
}
pkg_lint() {
@@ -837,10 +825,12 @@ pkg_conflicts() {
mv -f "$tar_dir/$p_name/$con" \
"$tar_dir/$p_name/$cho_dir/$p_name$con_name"
+ regex_escape "$con" "/$cho_dir/$p_name$con_name"
+
# Rewrite the package's manifest to update its location
# to its new spot (and name) in the choices directory.
- ssed "$con" "/$cho_dir/$p_name$con_name" \
- "$tar_dir/$p_name/$pkg_db/$p_name/manifest"
+ sed -i "s/$sea/$rep/" \
+ "$tar_dir/$p_name/$pkg_db/$p_name/manifest"
done
else
if "$grep" -Fxf "$cac_dir/$pid-m" -- "$@"; then
@@ -881,19 +871,20 @@ pkg_swap() {
log "Swapping '$2' from '$pkg_owns' to '$1'"
+ regex_escape "$2" "$PWD/$pkg_owns>${alt#*>}"
# Convert the current owner to an alternative and rewrite
# its manifest file to reflect this.
- dosu cp -f "'$2'" "'$pkg_owns>${alt#*>}'"
- ssed "'$2'" "'$PWD/$pkg_owns>${alt#*>}'" \
- "'../installed/$pkg_owns/manifest'" dosu
+ dosu cp -f "'$2'" "'$pkg_owns>${alt#*>}'"
+ dosu sed -i "'s/$sea/$rep/'" "'../installed/$pkg_owns/manifest'"
fi
+ regex_escape "$PWD/$alt" "$2"
# Convert the desired alternative to a real file and rewrite
# the manifest file to reflect this. The reverse of above.
- dosu mv -f "'$alt'" "'$2'"
- ssed "'$PWD/$alt'" "'$2'" "'../installed/$1/manifest'" dosu
+ dosu mv -f "'$alt'" "'$2'"
+ dosu sed -i "'s/$sea/$rep/'" "'../installed/$1/manifest'"
}
pkg_remove() {