fix ci syntax
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Simon Vieille 2023-09-29 16:38:28 +02:00
parent 50a788ab5c
commit 95e6c7f703
Signed by: deblan
GPG key ID: 579388D585F70417
2 changed files with 52 additions and 52 deletions

View file

@ -1,4 +1,4 @@
pipeline: steps:
shellcheck: shellcheck:
image: pipelinecomponents/shellcheck image: pipelinecomponents/shellcheck
commands: commands:

102
script
View file

@ -3,7 +3,7 @@
set -eu set -eu
usage() { usage() {
printf "Usage: %s [-l DEBUG_LEVEL] [-h]\n" "$0" printf "Usage: %s [-l DEBUG_LEVEL] [-h]\n" "$0"
} }
help() { help() {
@ -25,70 +25,70 @@ EOH
} }
on_interrupt() { on_interrupt() {
log -l notice "" log -l notice ""
log -l notice "Process aborted!" log -l notice "Process aborted!"
exit 130 exit 130
} }
main() { main() {
while getopts "l:h" option; do while getopts "l:h" option; do
case "${option}" in case "${option}" in
h) help; exit 0;; h) help; exit 0;;
l) LOG_VERBOSE="$OPTARG";; l) LOG_VERBOSE="$OPTARG";;
?) log -l error "$(usage)"; exit 1;; ?) log -l error "$(usage)"; exit 1;;
esac esac
done done
# log [-t] [-l debug|info|notice|warning|error] message # log [-t] [-l debug|info|notice|warning|error] message
exit 0 exit 0
} }
log() { log() {
LOG_VERBOSE="${LOG_VERBOSE:-info}" LOG_VERBOSE="${LOG_VERBOSE:-info}"
LEVEL=info LEVEL=info
TIME= TIME=
while getopts "tl:" option; do while getopts "tl:" option; do
case "${option}" in case "${option}" in
l) LEVEL="$OPTARG"; shift $((OPTIND-1));; l) LEVEL="$OPTARG"; shift $((OPTIND-1));;
t) TIME="$(printf "[%s] " "$(date +'%Y-%m-%dT%H:%M:%S.%s')")"; shift $((OPTIND-1));; t) TIME="$(printf "[%s] " "$(date +'%Y-%m-%dT%H:%M:%S.%s')")"; shift $((OPTIND-1));;
*) exit 1;; *) exit 1;;
esac esac
done done
if [ -t 2 ] && [ -z "${NO_COLOR-}" ]; then if [ -t 2 ] && [ -z "${NO_COLOR-}" ]; then
case "${LEVEL}" in case "${LEVEL}" in
debug) COLOR="$(tput setaf 3)";; debug) COLOR="$(tput setaf 3)";;
notice) COLOR="$(tput setaf 4)";; notice) COLOR="$(tput setaf 4)";;
warning) COLOR="$(tput setaf 5)";; warning) COLOR="$(tput setaf 5)";;
error) COLOR="$(tput setaf 1)";; error) COLOR="$(tput setaf 1)";;
*) COLOR="$(tput sgr0)";; *) COLOR="$(tput sgr0)";;
esac esac
fi fi
case "${LEVEL}" in case "${LEVEL}" in
debug) LEVEL=100;; debug) LEVEL=100;;
notice) LEVEL=250;; notice) LEVEL=250;;
warning) LEVEL=300;; warning) LEVEL=300;;
error) LEVEL=400;; error) LEVEL=400;;
*) LEVEL=200;; *) LEVEL=200;;
esac esac
case "${LOG_VERBOSE}" in case "${LOG_VERBOSE}" in
debug) LOG_VERBOSE_VALUE=100;; debug) LOG_VERBOSE_VALUE=100;;
notice) LOG_VERBOSE_VALUE=250;; notice) LOG_VERBOSE_VALUE=250;;
warning) LOG_VERBOSE_VALUE=300;; warning) LOG_VERBOSE_VALUE=300;;
error) LOG_VERBOSE_VALUE=400;; error) LOG_VERBOSE_VALUE=400;;
*) LOG_VERBOSE_VALUE=200;; *) LOG_VERBOSE_VALUE=200;;
esac esac
if [ $LEVEL -ge $LOG_VERBOSE_VALUE ]; then if [ $LEVEL -ge $LOG_VERBOSE_VALUE ]; then
printf "%s\n" "$*" | while IFS='' read -r LINE; do printf "%s\n" "$*" | while IFS='' read -r LINE; do
printf "%s%s%s\n" "${COLOR:-}" "${TIME:-}" "$LINE" >&2 printf "%s%s%s\n" "${COLOR:-}" "${TIME:-}" "$LINE" >&2
done done
fi fi
} }
trap on_interrupt INT trap on_interrupt INT