log
This commit is contained in:
11
download.sh
11
download.sh
@ -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"
|
||||||
|
|||||||
Reference in New Issue
Block a user