Blob Blame History Raw
From a7d8fc280c172ab023ce6170c33c323fb7c87adf Mon Sep 17 00:00:00 2001
From: Frederick Grose <fgrose@sugarlabs.org>
Date: Mon, 3 Sep 2018 17:01:53 -0400
Subject: [PATCH] dmsquash-live: Avoid grep and sed in this module.

strstr and variable string manipulations suffice.
---
 modules.d/90dmsquash-live/dmsquash-generator.sh  | 4 ++--
 modules.d/90dmsquash-live/dmsquash-live-root.sh  | 6 +++---
 modules.d/90dmsquash-live/module-setup.sh        | 2 +-
 modules.d/90dmsquash-live/parse-dmsquash-live.sh | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/modules.d/90dmsquash-live/dmsquash-generator.sh b/modules.d/90dmsquash-live/dmsquash-generator.sh
index 1129ddff..f57b1fc5 100755
--- a/modules.d/90dmsquash-live/dmsquash-generator.sh
+++ b/modules.d/90dmsquash-live/dmsquash-generator.sh
@@ -18,12 +18,12 @@ fi
 case "$liveroot" in
     live:LABEL=*|LABEL=*) \
         root="${root#live:}"
-        root="$(echo $root | sed 's,/,\\x2f,g')"
+        root="${root//\//\\x2f}"
         root="live:/dev/disk/by-label/${root#LABEL=}"
         rootok=1 ;;
     live:CDLABEL=*|CDLABEL=*) \
         root="${root#live:}"
-        root="$(echo $root | sed 's,/,\\x2f,g')"
+        root="${root//\//\\x2f}"
         root="live:/dev/disk/by-label/${root#CDLABEL=}"
         rootok=1 ;;
     live:UUID=*|UUID=*) \
diff --git a/modules.d/90dmsquash-live/dmsquash-live-root.sh b/modules.d/90dmsquash-live/dmsquash-live-root.sh
index 0f3d8f89..330ba3e9 100755
--- a/modules.d/90dmsquash-live/dmsquash-live-root.sh
+++ b/modules.d/90dmsquash-live/dmsquash-live-root.sh
@@ -109,15 +109,15 @@ do_live_overlay() {
 
     if [ -z "$overlay" ]; then
         pathspec="/${live_dir}/overlay-$l-$u"
-    elif ( echo $overlay | grep -q ":" ); then
+    elif strstr $overlay ":"; then
         # pathspec specified, extract
-        pathspec=$( echo $overlay | sed -e 's/^.*://' )
+        pathspec=${overlay##*:}
     fi
 
     if [ -z "$pathspec" -o "$pathspec" = "auto" ]; then
         pathspec="/${live_dir}/overlay-$l-$u"
     fi
-    devspec=$( echo $overlay | sed -e 's/:.*$//' )
+    devspec=${overlay%%:*}
 
     # need to know where to look for the overlay
     if [ -z "$setup" -a -n "$devspec" -a -n "$pathspec" -a -n "$overlay" ]; then
diff --git a/modules.d/90dmsquash-live/module-setup.sh b/modules.d/90dmsquash-live/module-setup.sh
index 48418a06..f251258f 100755
--- a/modules.d/90dmsquash-live/module-setup.sh
+++ b/modules.d/90dmsquash-live/module-setup.sh
@@ -22,7 +22,7 @@ installkernel() {
 
 # called by dracut
 install() {
-    inst_multiple umount dmsetup blkid dd losetup grep blockdev find
+    inst_multiple umount dmsetup blkid dd losetup blockdev find
     inst_multiple -o checkisomd5
     inst_hook cmdline 30 "$moddir/parse-dmsquash-live.sh"
     inst_hook cmdline 31 "$moddir/parse-iso-scan.sh"
diff --git a/modules.d/90dmsquash-live/parse-dmsquash-live.sh b/modules.d/90dmsquash-live/parse-dmsquash-live.sh
index 0eedf1f6..4d46a360 100755
--- a/modules.d/90dmsquash-live/parse-dmsquash-live.sh
+++ b/modules.d/90dmsquash-live/parse-dmsquash-live.sh
@@ -20,12 +20,12 @@ modprobe -q loop
 case "$liveroot" in
     live:LABEL=*|LABEL=*) \
         root="${root#live:}"
-        root="$(echo $root | sed 's,/,\\x2f,g')"
+        root="${root//\//\\x2f}"
         root="live:/dev/disk/by-label/${root#LABEL=}"
         rootok=1 ;;
     live:CDLABEL=*|CDLABEL=*) \
         root="${root#live:}"
-        root="$(echo $root | sed 's,/,\\x2f,g')"
+        root="${root//\//\\x2f}"
         root="live:/dev/disk/by-label/${root#CDLABEL=}"
         rootok=1 ;;
     live:UUID=*|UUID=*) \