From d03c206532d195e3d8f4d8db10de7694511c026f Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Tue, 1 Dec 2020 23:49:01 +0300 Subject: . --- vsvs.sh | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) mode change 100644 => 100755 vsvs.sh diff --git a/vsvs.sh b/vsvs.sh old mode 100644 new mode 100755 index 0c7ce88..4362729 --- a/vsvs.sh +++ b/vsvs.sh @@ -1,20 +1,24 @@ res="" met=false -while read line +while IFS="" read str do - value="$(echo -n "$line" | sed 's/ .*//')" - if [ "${line:0:1}" == " " ] + if [ -z "${str##* *}" ] then - if [ $met == true ] - then - res="${res}\n${value}" - fi + key="${str%% *}" + val="${str#* }" else - if [ "$(echo -n "${line}" | sed 's/[^ ]* //')" == "$1" ] - then - met=true - res="${value}" - fi + key="${str}" + val="" + fi + if [ -z "${key}" ] && [ $met == true ] + then + res="${res}"$'\n'"${val}" + elif [ "${key}" == "$1" ] + then + met=true + res="${val}" + else + met=false fi done echo -n "${res}" -- cgit v1.2.3