From 4a4d1b2ba9a23a55c3a7e53f82c366efbd37a6b3 Mon Sep 17 00:00:00 2001 From: j-hc <25510067+j-hc@users.noreply.github.com> Date: Sat, 13 Aug 2022 03:18:51 +0300 Subject: [PATCH] use shell expansion --- scripts/customize.sh | 14 ++++++++++---- scripts/post-fs-data.sh | 4 +++- scripts/service.sh | 3 ++- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/scripts/customize.sh b/scripts/customize.sh index a7da7da..65a7371 100755 --- a/scripts/customize.sh +++ b/scripts/customize.sh @@ -1,9 +1,10 @@ # shellcheck disable=SC2148,SC2086,SC2115 ui_print "" -am force-stop __PKGNAME grep __PKGNAME /proc/mounts | while read -r line; do ui_print "* Un-mount" - echo "$line" | cut -d" " -f2 | xargs -r umount -l + line=${line#*' '} + line=${line%%' '*} + umount -l ${line%%\\*} # trims \040(deleted) done if [ $ARCH = "arm" ]; then @@ -19,7 +20,12 @@ else fi set_perm_recursive $MODPATH/bin 0 0 0755 0777 -BASEPATH=$(pm path __PKGNAME | grep base | cut -d: -f2) +basepath() { + basepath=$(pm path __PKGNAME | grep base) + echo ${basepath#*:} +} + +BASEPATH=$(basepath) if [ -n "$BASEPATH" ] && cmpr $BASEPATH $MODPATH/stock.apk; then ui_print "* Installed __PKGNAME and module stock.apk are identical" ui_print "* Skipping stock APK installation" @@ -30,7 +36,7 @@ else ui_print "ERROR: APK installation failed!" abort "${op}" fi - BASEPATH=$(pm path __PKGNAME | grep base | cut -d: -f2) + BASEPATH=$(basepath) fi ui_print "* Patching __PKGNAME (v__MDVRSN) on the fly" diff --git a/scripts/post-fs-data.sh b/scripts/post-fs-data.sh index 1007e54..38f01e7 100644 --- a/scripts/post-fs-data.sh +++ b/scripts/post-fs-data.sh @@ -1,4 +1,6 @@ #!/system/bin/sh grep __PKGNAME /proc/mounts | while read -r line; do - echo "$line" | cut -d" " -f2 | xargs -r umount -l + line=${line#*' '} + line=${line%%' '*} + umount -l ${line%%\\*} done diff --git a/scripts/service.sh b/scripts/service.sh index 34a356a..446ff86 100644 --- a/scripts/service.sh +++ b/scripts/service.sh @@ -4,7 +4,8 @@ MODDIR=${0%/*} until [ "$(getprop sys.boot_completed)" = 1 ]; do sleep 1 done -BASEPATH=$(pm path __PKGNAME | grep base | cut -d: -f2) +BASEPATH=$(pm path __PKGNAME | grep base) +BASEPATH=${BASEPATH#*:} if [ "$BASEPATH" ]; then chcon u:object_r:apk_data_file:s0 $MODDIR/base.apk mount -o bind $MODDIR/base.apk $BASEPATH