From f229b632cbc31c5efad109589cd36b07bcd48817 Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Sat, 5 Dec 2020 11:35:52 +0300 Subject: . --- vsvs | 31 +++++++++++++++++++++++++++++++ vsvs-get | 25 +------------------------ vsvs-map | 29 ----------------------------- vsvs-sum | 29 ----------------------------- 4 files changed, 32 insertions(+), 82 deletions(-) create mode 100755 vsvs mode change 100644 => 100755 vsvs-get delete mode 100644 vsvs-map delete mode 100644 vsvs-sum diff --git a/vsvs b/vsvs new file mode 100755 index 0000000..7977ec3 --- /dev/null +++ b/vsvs @@ -0,0 +1,31 @@ +#!/bin/bash +res="" +buf="" +key="" +while IFS="" read str +do + if [ -z "${str##* *}" ] + then + newkey="${str%% *}" + val="${str#* }" + else + newkey="${str}" + val="" + fi + if [ -z "${newkey}" ] + then + buf="${buf}"$'\n'"${val}" + else + if [ -n "${buf}" ] + then + eval $1 + fi + key="${newkey}" + buf="${val}" + fi +done +if [ -n "${buf}" ] +then + eval $1 +fi +echo -n "${res}" diff --git a/vsvs-get b/vsvs-get old mode 100644 new mode 100755 index e7ab391..b3ab53f --- a/vsvs-get +++ b/vsvs-get @@ -1,25 +1,2 @@ #!/bin/bash -res="" -met=false -while IFS="" read str -do - if [ -z "${str##* *}" ] - then - key="${str%% *}" - val="${str#* }" - else - 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}" +vsvs "if [ \"\${key}\" == \"$1\" ]; then res=\"\${buf}\"; fi" diff --git a/vsvs-map b/vsvs-map deleted file mode 100644 index dbe1ecb..0000000 --- a/vsvs-map +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -res="" -buf="" -while IFS="" read str -do - if [ -z "${str##* *}" ] - then - key="${str%% *}" - val="${str#* }" - else - key="${str}" - val="" - fi - if [ -z "${key}" ] - then - buf="${buf}"$'\n'"${val}" - else - if [ -n "${buf}" ] - then - res="${res}$(echo -n "${buf}" | $1)" - fi - buf="${val}" - fi -done -if [ -n "${buf}" ] -then - res="${res}$(echo -n "${buf}" | $1)" -fi -echo -n "${res}" diff --git a/vsvs-sum b/vsvs-sum deleted file mode 100644 index 1684dd8..0000000 --- a/vsvs-sum +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/bash -res="" -buf="" -while IFS="" read str -do - if [ -z "${str##* *}" ] - then - key="${str%% *}" - val="${str#* }" - else - key="${str}" - val="" - fi - if [ -z "${key}" ] - then - buf="${buf}"$'\n'"${val}" - else - if [ -n "${buf}" ] - then - res="$(echo -n "${buf}" | $1 "${res}")" - fi - buf="${val}" - fi -done -if [ -n "${buf}" ] -then - res="$(echo -n "${buf}" | $1 "${res}")" -fi -echo -n "${res}" -- cgit v1.2.3