Blame SOURCES/0032-appliance-use-bash-features-for-string-matching-in-f.patch

e76f14
From a9ce8e635ebac7e3924757c93a84619943862167 Mon Sep 17 00:00:00 2001
e76f14
From: Pino Toscano <ptoscano@redhat.com>
e76f14
Date: Tue, 22 Mar 2016 15:48:53 +0100
e76f14
Subject: [PATCH] appliance: use bash features for string matching in files
e76f14
e76f14
Read the content of /proc/cmdline using bash features, and use its
e76f14
[[ ... ]] expression to find texts in a variable.
e76f14
e76f14
This shaves off 5 grep invocations.
e76f14
e76f14
(cherry picked from commit bb5d30ab2af5720775c63179afdec3ad9efd510d)
e76f14
---
e76f14
 appliance/init | 12 +++++++-----
e76f14
 1 file changed, 7 insertions(+), 5 deletions(-)
e76f14
e76f14
diff --git a/appliance/init b/appliance/init
e76f14
index 3b76486..fd56033 100755
e76f14
--- a/appliance/init
e76f14
+++ b/appliance/init
e76f14
@@ -77,7 +77,9 @@ $UDEVD --daemon #--debug
e76f14
 udevadm trigger
e76f14
 udevadm settle --timeout=600
e76f14
 
e76f14
-if grep -sq selinux=1 /proc/cmdline; then
e76f14
+cmdline=$(
e76f14
+
e76f14
+if [[ $cmdline == *selinux=1* ]]; then
e76f14
   mount -t selinuxfs none /sys/fs/selinux
e76f14
 fi
e76f14
 
e76f14
@@ -93,16 +95,16 @@ shopt -u nullglob
e76f14
 hwclock -u -s
e76f14
 
e76f14
 # Parse the kernel command line.
e76f14
-if grep -sq guestfs_verbose=1 /proc/cmdline; then
e76f14
+if [[ $cmdline == *guestfs_verbose=1* ]]; then
e76f14
     guestfs_verbose=1
e76f14
 fi
e76f14
-if grep -sq guestfs_network=1 /proc/cmdline; then
e76f14
+if [[ $cmdline == *guestfs_network=1* ]]; then
e76f14
     guestfs_network=1
e76f14
 fi
e76f14
-if grep -sq guestfs_rescue=1 /proc/cmdline; then
e76f14
+if [[ $cmdline == *guestfs_rescue=1* ]]; then
e76f14
     guestfs_rescue=1
e76f14
 fi
e76f14
-if grep -sq guestfs_noreboot=1 /proc/cmdline; then
e76f14
+if [[ $cmdline == *guestfs_noreboot=1* ]]; then
e76f14
     guestfs_noreboot=1
e76f14
 fi
e76f14
 eval `grep -Eo 'guestfs_channel=[^[:space:]]+' /proc/cmdline`
e76f14
-- 
7af31e
1.8.3.1
e76f14