add bashutils

This commit is contained in:
Micyp
2021-07-27 15:32:31 +02:00
parent e1b576a4b7
commit 4183072ea8

16
bashutils Normal file
View File

@@ -0,0 +1,16 @@
#!/hint/bash
function shasum {
command shasum <<<"$1" | awk '{ print $1 }'
}
# once <command>
function once {
local flagname="__onceflag_$(shasum "$*")"
if [[ -z ${!flagname} ]]; then
declare -g "${flagname}"=1
"$@"
fi
}