From 85848755aa409ab9dd6f63f1772e21371ec45e18 Mon Sep 17 00:00:00 2001 From: Eugene Syromyatnikov Date: Wed, 6 Feb 2019 00:49:47 +0100 Subject: [PATCH] xlat/gen.sh: speedup, part 3 * xlat/gen.sh (cond_def): Use parameter substitution instead of sed for xlat line parsing. Co-Authored-by: Dmitry V. Levin --- xlat/gen.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/xlat/gen.sh b/xlat/gen.sh index 05527a93..0a9c9736 100755 --- a/xlat/gen.sh +++ b/xlat/gen.sh @@ -26,12 +26,16 @@ cond_def() line="$1"; shift local val - val="$(printf %s "$line" | - sed -r -n 's/^([[:alpha:]_][[:alnum:]_]*).*$/\1/p')" - - local def - def="$(printf %s "${line}" | - sed -r -n 's/^[^[:space:]]+[[:space:]]+([^[:space:]].*)$/\1/p')" + val="${line%%[!A-Za-z0-9_]*}" + + local t def= + t="${line#*[ ]}" + if [ "$line" != "$t" ]; then + while [ "$def" != "$t" ]; do + def="$t" + t="${t##[ ]}" + done + fi if [ -n "$def" ]; then printf "%s\n" \ -- 2.50.1