From e82157e5418706f4a39476e6e37389b7b1c7c883 Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Thu, 3 Dec 2020 15:31:40 +0300 Subject: . --- default.do | 6 +++--- vsvs-get | 25 +++++++++++++++++++++++++ vsvs-map | 22 ++++++++++++++++++++++ vsvs-sum | 22 ++++++++++++++++++++++ vsvs.sh | 25 ------------------------- 5 files changed, 72 insertions(+), 28 deletions(-) create mode 100644 vsvs-get create mode 100644 vsvs-map create mode 100644 vsvs-sum delete mode 100755 vsvs.sh diff --git a/default.do b/default.do index ee79c29..617cc1c 100755 --- a/default.do +++ b/default.do @@ -1,5 +1,5 @@ #!/bin/sh -export title="$(vsvs.sh title < $1.vs)" -export content="$(vsvs.sh content < $1.vs)" -echo -n "$(vsvs.sh template < articles.vs)" | shelter >$3; +export title="$(vsvs-get title < $1.vs)" +export content="$(vsvs-get content < $1.vs)" +echo -n "$(vsvs-get template < articles.vs)" | shelter >$3; redo-ifchange $1.vs articles.vs diff --git a/vsvs-get b/vsvs-get new file mode 100644 index 0000000..e7ab391 --- /dev/null +++ b/vsvs-get @@ -0,0 +1,25 @@ +#!/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}" diff --git a/vsvs-map b/vsvs-map new file mode 100644 index 0000000..e1cbd49 --- /dev/null +++ b/vsvs-map @@ -0,0 +1,22 @@ +#!/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 + res="${res}$(echo -n "${buf}" | $1)" + buf="${val}" + fi +done +echo -n "${res}" diff --git a/vsvs-sum b/vsvs-sum new file mode 100644 index 0000000..f861e0f --- /dev/null +++ b/vsvs-sum @@ -0,0 +1,22 @@ +#!/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 + res="$(echo -n "${buf}" | $1 "${res}")" + buf="${val}" + fi +done +echo -n "${res}" diff --git a/vsvs.sh b/vsvs.sh deleted file mode 100755 index e7ab391..0000000 --- a/vsvs.sh +++ /dev/null @@ -1,25 +0,0 @@ -#!/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}" -- cgit v1.2.3