cascading-pr/cascading-pr-lib.sh
2023-10-11 18:05:11 +02:00

52 lines
651 B
Bash

# SPDX-License-Identifier: MIT
declare -A options
VERBOSE=false
DEBUG=false
: ${EXIT_ON_ERROR:=true}
function debug() {
DEBUG=true
set -x
PS4='${BASH_SOURCE[0]}:$LINENO: ${FUNCNAME[0]}: '
}
function verbose() {
VERBOSE=true
}
function log() {
echo "$@" >&2
}
function log_error() {
log "$@"
}
function log_verbose() {
if $VERBOSE ; then
log "$@"
fi
}
function log_info() {
log "$@"
}
function fatal_error() {
log_error "$@"
if $EXIT_ON_ERROR ; then
exit 1
else
return 1
fi
}
function host_port() {
local url="$1"
local host_port="${url##http*://}"
echo ${host_port%%/}
}