mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-25 18:55:24 +00:00
Changed to use sed for regex pattern matching
The code was using a mixture of shell patterns and sed regular expression. Changed code to just used sed regex. This will let me use more complex regex that are needed for adding PARTUUID to uuids. BUG=chromium:241572 TEST=./security_test_image BRANCH=none Change-Id: I2e8570051b31d580ae36cb82f05383a33236b88e Reviewed-on: https://gerrit.chromium.org/gerrit/51503 Reviewed-by: Mike Frysinger <vapier@chromium.org> Commit-Queue: Paul Taysom <taysom@chromium.org> Tested-by: Paul Taysom <taysom@chromium.org>
This commit is contained in:
@@ -65,6 +65,8 @@ main() {
|
|||||||
local testfail=0
|
local testfail=0
|
||||||
# A buffer to include useful information that we dump when things fail.
|
# A buffer to include useful information that we dump when things fail.
|
||||||
local output
|
local output
|
||||||
|
# Copy of a string before it has been through sed
|
||||||
|
local pre_sed
|
||||||
|
|
||||||
if [[ $# -ne 1 ]] && [[ $# -ne 2 ]]; then
|
if [[ $# -ne 1 ]] && [[ $# -ne 2 ]]; then
|
||||||
usage
|
usage
|
||||||
@@ -170,14 +172,11 @@ main() {
|
|||||||
|
|
||||||
# Ensure all other required regex params are present.
|
# Ensure all other required regex params are present.
|
||||||
for param in "${required_kparams_regex[@]}"; do
|
for param in "${required_kparams_regex[@]}"; do
|
||||||
if [[ "$kparams_nodm" != *$param* ]]; then
|
pre_sed=" ${kparams_nodm} "
|
||||||
echo "Kernel parameters missing required value: $param"
|
kparams_nodm=$(echo "${pre_sed}" | sed "s${M} ${param} ${M} ${M}")
|
||||||
|
if [[ "${pre_sed}" == "${kparams_nodm}" ]]; then
|
||||||
|
echo "Kernel parameters missing required value: ${param}"
|
||||||
testfail=1
|
testfail=1
|
||||||
else
|
|
||||||
# Remove matched params as we go. If all goes well, kparams_nodm
|
|
||||||
# will be nothing left but whitespace by the end.
|
|
||||||
kparams_nodm=$(echo " ${kparams_nodm} " |
|
|
||||||
sed "s${M} ${param} ${M} ${M}")
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user