From 425181aff1f0139bc23609aece48280c38b07542 Mon Sep 17 00:00:00 2001 From: Suikan <26223147+suikan4github@users.noreply.github.com> Date: Sat, 7 May 2022 22:02:42 +0900 Subject: [PATCH] Fix the duplicate awk match. Now, it exits the process when the first pattern is procesed. --- script/lib/common.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/script/lib/common.sh b/script/lib/common.sh index a1bd2f5..c37b0f9 100644 --- a/script/lib/common.sh +++ b/script/lib/common.sh @@ -143,20 +143,21 @@ function confirmation(){ # Add -l or -L parameter to the size. The lvcreate command have two size parameter. - # -L ###[M|G|T|m|g|t] : Size by absolute value. # -l ###%[FREE|VG|PVS|ORIGIN] : Size by relative value. + # -L ###[M|G|T|m|g|t] : Size by absolute value. + # Too preven the duplicated match, awk exists the process after it match the /%/ pattern. # If Unit is not specified, installation will fail. - LVSWAPSIZE=$(echo "${LVSWAPSIZE}" | awk '/M|G|T|m|g|t/{print "-L", $0} /%/ {print "-l", $0}') + LVSWAPSIZE=$(echo "${LVSWAPSIZE}" | awk '/%/{print "-l", $0; exit} /M|G|T|m|g|t/{print "-L", $0}') export LVSWAPSIZE - LVROOTSIZE=$(echo "${LVROOTSIZE}" | awk '/M|G|T|m|g|t/{print "-L", $0} /%/ {print "-l", $0}') + LVROOTSIZE=$(echo "${LVROOTSIZE}" | awk '/%/{print "-l", $0; exit} /M|G|T|m|g|t/{print "-L", $0}') export LVROOTSIZE - LVEXT1SIZE=$(echo "${LVEXT1SIZE}" | awk '/M|G|T|m|g|t/{print "-L", $0} /%/ {print "-l", $0}') + LVEXT1SIZE=$(echo "${LVEXT1SIZE}" | awk '/%/{print "-l", $0; exit} /M|G|T|m|g|t/{print "-L", $0}') export LVEXT1SIZE - LVEXT2SIZE=$(echo "${LVEXT2SIZE}" | awk '/M|G|T|m|g|t/{print "-L", $0} /%/ {print "-l", $0}') + LVEXT2SIZE=$(echo "${LVEXT2SIZE}" | awk '/%/{print "-l", $0; exit} /M|G|T|m|g|t/{print "-L", $0}') export LVEXT2SIZE # succesfull return