commit 86d374215d567c7690e39b5290dea7ce5c8d2e01
parent 53afdda83b6632fa8178b9ba8167e06af8b76c3c
Author: Cem Keylan <cem@ckyln.com>
Date: Sat, 9 May 2020 18:36:21 +0300
kiss: remove esc function
Diffstat:
1 file changed, 2 insertions(+), 11 deletions(-)
diff --git a/kiss b/kiss
@@ -66,15 +66,6 @@ as_root() {
esac
}
-esc() {
- # Escape all required characters in both the search and
- # replace portions of two strings for use in a 'sed' call
- # as "plain-text".
- printf 's/^%s$/%s/' \
- "$(printf %s "$1" | sed 's/[]\/$*.^[]/\\&/g')" \
- "$(printf %s "$2" | sed 's/[\/&]/\\&/g')"
-}
-
pop() {
# Remove an item from a "string list". This allows us
# to remove a 'sed' call and reuse this code throughout.
@@ -923,7 +914,7 @@ pkg_swap() {
# its manifest file to reflect this. We then resort this file
# so no issues arise when removing packages.
cp -Pf "$2" "$pkg_owns>${alt#*>}"
- sed "$(esc "$2" "$PWD/$pkg_owns>${alt#*>}")" \
+ sed "s#^$2#$PWD/$pkg_owns>${alt#*>}#" \
"../installed/$pkg_owns/manifest" |
sort -r -o "../installed/$pkg_owns/manifest"
fi
@@ -931,7 +922,7 @@ pkg_swap() {
# Convert the desired alternative to a real file and rewrite
# the manifest file to reflect this. The reverse of above.
mv -f "$alt" "$2"
- sed "$(esc "$PWD/$alt" "$2")" "../installed/$1/manifest" |
+ sed "s#^$PWD/$alt#$2#" "../installed/$1/manifest" |
sort -r -o "../installed/$1/manifest"
}