This commit is contained in:
Urban Modig
2025-10-01 11:06:25 +02:00
parent 5c5a15ea2a
commit 27d4318160

View File

@ -12,11 +12,12 @@ set -Eeuo pipefail
IFS=$'\n\t' IFS=$'\n\t'
SCRIPT_NAME=${0##*/} SCRIPT_NAME=${0##*/}
VERSION="1.2.0" VERSION="1.2.1"
# ------------------------------- logging & utils ------------------------------- # ------------------------------- logging & utils -------------------------------
log() { printf '[%s] %s\n' "$(date '+%F %T%z')" "$*"; } log() { printf '[%s] %s
die() { log "ERROR: $*" >&2; exit 1; } ' "$(date '+%F %T%z')" "$*" >&2; }
die() { log "ERROR: $*"; exit 1; }
need() { command -v "$1" >/dev/null 2>&1 || die "Kräver '$1' i PATH"; } need() { command -v "$1" >/dev/null 2>&1 || die "Kräver '$1' i PATH"; }
need curl need curl
@ -27,6 +28,8 @@ need grep
need cut need cut
need dirname need dirname
log "Starting $SCRIPT_NAME v$VERSION (PID $$)"
# Safer temp dir for partial files, etc. # Safer temp dir for partial files, etc.
TMPDIR=${TMPDIR:-/tmp} TMPDIR=${TMPDIR:-/tmp}
WORKDIR=$(mktemp -d "$TMPDIR/${SCRIPT_NAME%.sh}.XXXXXX") WORKDIR=$(mktemp -d "$TMPDIR/${SCRIPT_NAME%.sh}.XXXXXX")
@ -311,7 +314,7 @@ while getopts ":ndc:p:f:h" opt; do
esac esac
done done
(( DEBUG )) && set -x (( DEBUG )) && { log "Debug mode enabled"; set -x; }
# Enforce mutual exclusivity between -c, -p, -f # Enforce mutual exclusivity between -c, -p, -f
set -- "$collection" "$post" "$file" set -- "$collection" "$post" "$file"
@ -331,4 +334,4 @@ elif [[ -n $file ]]; then
fi fi
# cleanup happens via trap # cleanup happens via trap
exit 0 exit 0