From 4183072ea89370d8c6683d62f678000877bd57d2 Mon Sep 17 00:00:00 2001 From: Micyp Date: Tue, 27 Jul 2021 15:32:31 +0200 Subject: [PATCH] add bashutils --- bashutils | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 bashutils diff --git a/bashutils b/bashutils new file mode 100644 index 0000000..7f8002a --- /dev/null +++ b/bashutils @@ -0,0 +1,16 @@ +#!/hint/bash + +function shasum { + command shasum <<<"$1" | awk '{ print $1 }' +} + +# once +function once { + local flagname="__onceflag_$(shasum "$*")" + if [[ -z ${!flagname} ]]; then + declare -g "${flagname}"=1 + "$@" + fi +} + +