first commit
This commit is contained in:
commit
3d6c49df65
16 files changed
+1137
No files matched your search
Executable
+40
@@ -0,0 +1,40 @@
|
||||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
log() {
|
||||
printf '%s %s\n' "$(date -u '+%Y-%m-%dT%H:%M:%SZ')" "$*"
|
||||
}
|
||||
|
||||
fatal() {
|
||||
log "ERROR: $*" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
require_cmd() {
|
||||
command -v "$1" >/dev/null 2>&1 || fatal "required command not found: $1"
|
||||
}
|
||||
|
||||
trim_trailing_slash() {
|
||||
local value=$1
|
||||
while [[ "$value" == */ ]]; do value=${value%/}; done
|
||||
printf '%s' "$value"
|
||||
}
|
||||
|
||||
yaml_quote() {
|
||||
python3 - "$1" <<'PY'
|
||||
import json, sys
|
||||
print(json.dumps(sys.argv[1]))
|
||||
PY
|
||||
}
|
||||
|
||||
read_first_field() {
|
||||
local file=$1 key=$2
|
||||
awk -v key="$key" 'BEGIN{IGNORECASE=1} $0 ~ "^" key ":[[:space:]]*" {sub(/^[^:]+:[[:space:]]*/, ""); print; exit}' "$file"
|
||||
}
|
||||
|
||||
atomic_write() {
|
||||
local path=$1
|
||||
local tmp="${path}.tmp.$$"
|
||||
cat > "$tmp"
|
||||
mv -f "$tmp" "$path"
|
||||
}
|
||||
Reference in new issue
Block a user