#!/bin/bash # Sentry CLI installer. # # curl -fsSL https://cli.sentry.dev/install | bash # # This script only fetches the right `sentry` binary for this machine. The # binary installs itself: `sentry cli setup` picks the install directory, # updates PATH, and installs shell completions and agent skills. # # The steps, in order (see main() below): # # 1. Read the command-line flags. # 2. Work out which build this machine needs (OS, CPU, libc). # 3. Find that build for the requested version (stable or nightly). # 4. Download it into the install directory and verify it. # 5. Hand off to `sentry cli setup`, and optionally `sentry init`. # # Everything is a function, and main() runs on the last line. If the download # of this script is cut off, bash runs nothing instead of half an installer. set -euo pipefail RED='\033[0;31m' MUTED='\033[0;2m' NC='\033[0m' # Installer errors go to Sentry through the envelope API, using the CLI's # public write-only DSN. No PII is collected. Opt out: SENTRY_CLI_NO_TELEMETRY=1 SENTRY_DSN_KEY="1188a86f3f8168f089450587b00bca66" SENTRY_INGEST="https://o1.ingest.us.sentry.io" SENTRY_PROJECT_ID="4510776311808000" REGISTRY_URL="https://release-registry.services.sentry.io/apps/sentry" GITHUB_REPO="getsentry/toolkit" GHCR_REPO="ghcr.io/v2/getsentry/toolkit" # Retry transient network failures (timeouts, refused connections, HTTP 408, # 429, and 5xx) with curl's exponential backoff. The binary needs glibc 2.28 # or macOS 11, whose curl (7.61, 7.64) has --retry-connrefused (7.52) but not # --retry-all-errors (7.71). curl_retry=(--retry 3 --retry-connrefused --retry-max-time 60) no_room_message="There is not enough room to download sentry (about 140 MB) into the install directory, or it is not writable. Free up space or set SENTRY_INSTALL_DIR to another directory, then retry." # Installer state. The steps below fill these in; error reports read them. requested_version="${SENTRY_VERSION:-}" # "", "nightly", or a version no_modify_path=false no_completions=false no_agent_skills=false os="" # darwin, linux, or windows arch="" # x64 or arm64 libc_variant="" # set to musl only to report why the install stopped suffix="" # ".exe" on Windows asset="" # release file name, such as sentry-linux-x64 version="" # the exact version being installed gz_url="" # release downloads and their SHA-256 checksums gz_sha="" raw_url="" raw_sha="" registry_status="" # HTTP status of the release registry lookup # Download paths, all in the install directory. plan_download_paths sets them. binary="" # the downloaded binary blob_file="" # the downloaded .gz, before unpacking init_binary="" # hard link to the binary for `sentry init` main() { parse_args "$@" detect_platform plan_download_paths if [[ "$requested_version" == "nightly" ]]; then download_nightly else resolve_stable_release download_stable fi chmod +x "$binary" link_init_binary # From here on, a failure belongs to sentry itself, not to the installer: # exit with its status instead of reporting it as an installer bug. trap - ERR run_setup if [[ "${SENTRY_INIT:-}" == "1" ]]; then # `sentry init` only prints the agent setup guide, so it needs no terminal. "$init_binary" init fi } # --------------------------------------------------------------------------- # Command line # --------------------------------------------------------------------------- usage() { cat < Install a specific version (e.g., 0.2.0) or "nightly" --no-modify-path Don't modify shell config files (.zshrc, .bashrc, etc.) --no-completions Don't install shell completions --no-agent-skills Don't install agent skills Environment Variables: SENTRY_INSTALL_DIR Override the installation directory SENTRY_VERSION Install a specific version (e.g., 0.42.2, nightly) SENTRY_INIT Set to 1 to run \`sentry init\` after installing SENTRY_CLI_NO_TELEMETRY Set to 1 to disable installer error reporting Examples: curl -fsSL https://cli.sentry.dev/install | bash curl -fsSL https://cli.sentry.dev/install | SENTRY_INIT=1 bash curl -fsSL https://cli.sentry.dev/install | bash -s -- --version nightly curl -fsSL https://cli.sentry.dev/install | bash -s -- --version 0.42.2 curl -fsSL https://cli.sentry.dev/install | SENTRY_VERSION=nightly bash curl -fsSL https://cli.sentry.dev/install | SENTRY_INSTALL_DIR="$HOME/.local/bin" bash EOF } # Unknown arguments are ignored. parse_args() { while [[ $# -gt 0 ]]; do case "$1" in -h|--help) usage; exit 0 ;; -v|--version) [[ -n "${2:-}" ]] || die "Error: --version requires a version argument" "args" requested_version="$2" shift 2 ;; --no-modify-path) no_modify_path=true; shift ;; --no-completions) no_completions=true; shift ;; --no-agent-skills) no_agent_skills=true; shift ;; *) shift ;; esac done } # --------------------------------------------------------------------------- # Output and error reporting # --------------------------------------------------------------------------- # Usage: muted . Prints a dimmed progress line. muted() { printf '%b%s%b\n' "$MUTED" "$*" "$NC" } # Usage: die . Prints the message, reports it, and exits. die() { printf '%b%s%b\n' "$RED" "$1" "$NC" >&2 report_error "$1" "${2:-unknown}" exit 1 } # Usage: report_error . Sends an error event to Sentry in a # background subshell, so it never slows down or fails the install. report_error() { # Respect the same opt-out as the CLI binary. [[ "${SENTRY_CLI_NO_TELEMETRY:-}" == "1" ]] && return 0 ( # Telemetry must never fail the script or report its own failures. set +e trap - ERR # Escape a value for safe JSON string interpolation. _esc() { printf '%s' "$1" | sed 's/\\/\\\\/g;s/"/\\"/g' | tr '\n' ' '; } local event_id timestamp msg step channel install_version event_id=$(gen_uuid | tr -d '-') timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ" 2>/dev/null || echo "") msg=$(_esc "${1:-unknown error}") step=$(_esc "${2:-unknown}") channel=$(_esc "${requested_version:-stable}") install_version=$(_esc "${version:-unknown}") local header item event header="{\"event_id\":\"${event_id}\",\"dsn\":\"https://${SENTRY_DSN_KEY}@o1.ingest.us.sentry.io/${SENTRY_PROJECT_ID}\"}" item='{"type":"event"}' event="{\"event_id\":\"${event_id}\",\"timestamp\":\"${timestamp}\",\"platform\":\"other\",\"level\":\"error\",\"logger\":\"install\",\"server_name\":\"install-script\",\"message\":{\"formatted\":\"${msg}\"},\"tags\":{\"os\":\"${os:-unknown}\",\"arch\":\"${arch:-unknown}\",\"libc\":\"${libc_variant:-glibc}\",\"channel\":\"${channel}\",\"step\":\"${step}\",\"install.version\":\"${install_version}\"},\"contexts\":{\"runtime\":{\"name\":\"bash\",\"version\":\"${BASH_VERSION:-unknown}\"}}}" curl -sf --max-time 2 \ -H "Content-Type: application/x-sentry-envelope" \ -H "X-Sentry-Auth: Sentry sentry_key=${SENTRY_DSN_KEY},sentry_version=7" \ -d "$(printf '%s\n%s\n%s' "$header" "$item" "$event")" \ "${SENTRY_INGEST}/api/${SENTRY_PROJECT_ID}/envelope/" \ >/dev/null 2>&1 ) & } # Prints a random UUID. Tries /proc, then uuidgen, then awk. gen_uuid() { if [[ -r /proc/sys/kernel/random/uuid ]]; then cat /proc/sys/kernel/random/uuid elif command -v uuidgen >/dev/null 2>&1; then uuidgen | tr '[:upper:]' '[:lower:]' else awk 'BEGIN{srand();for(i=1;i<=32;i++)printf "%c",substr("0123456789abcdef",int(rand()*16)+1,1);print ""}' fi } # The ERR trap: reports any failure that no `die` call explains. # $BASH_COMMAND is the failing command's unexpanded source text, so the report # names the command without the paths or values it ran with. on_unexpected_failure() { local status=$1 line=$2 failed_command=$3 function_name=$4 # A failing command substitution also fails the command that contains it, # which reports from the parent shell. if (( BASH_SUBSHELL > 0 )); then exit "$status" fi local where="line ${line}" if [[ -n "$function_name" ]]; then where="${where} in ${function_name}()" fi die "Unexpected failure at ${where} (exit ${status}): ${failed_command:0:200}" "trap" } # --------------------------------------------------------------------------- # Step 2: which build does this machine need? # --------------------------------------------------------------------------- detect_platform() { case "$(uname -s)" in Darwin*) os="darwin" ;; Linux*) os="linux" ;; MINGW*|MSYS*|CYGWIN*) os="windows" ;; *) die "Unsupported OS: $(uname -s)" "detect-os" ;; esac arch=$(uname -m) case "$arch" in x86_64) arch="x64" ;; aarch64|arm64) arch="arm64" ;; *) die "Unsupported architecture: $arch" "detect-arch" ;; esac # The standalone binary is a Node.js SEA, and official Node.js builds # target glibc. if [[ "$os" == "linux" ]] && is_musl; then libc_variant="musl" die "The standalone binary requires glibc. On musl (Alpine), install Node.js and run: npm install -g sentry" "detect-libc" fi if [[ "$os" == "windows" ]]; then suffix=".exe" [[ "$arch" == "x64" ]] || die "Unsupported: windows-$arch (only windows-x64 is supported)" "detect-arch" fi asset="sentry-${os}-${arch}${suffix}" } # Succeeds on musl-based Linux, such as Alpine. is_musl() { # `ldd --version` names the running libc, so trust it when it exists. # musl's ldd exits non-zero, so capture its output instead of piping it # under pipefail. if command -v ldd >/dev/null 2>&1; then grep -qi musl <<<"$(ldd --version 2>&1 || true)" return fi # Without ldd, look for the musl dynamic linker. glibc systems can have it # too when the musl package is installed. local musl_arch case "$arch" in x64) musl_arch="x86_64" ;; arm64) musl_arch="aarch64" ;; esac [ -f "/lib/ld-musl-${musl_arch}.so.1" ] } # --------------------------------------------------------------------------- # Where downloads go # --------------------------------------------------------------------------- # Downloads go straight into the directory `sentry cli setup` will install # into, and the binary takes the name of setup's own temp file. Setup then # renames it into place instead of copying it, and a small or full /tmp does # not matter. The EXIT trap removes whatever setup did not take. plan_download_paths() { local dir dir=$(setup_install_dir) if [[ -z "$dir" ]]; then dir="${TMPDIR:-${TMP:-${TEMP:-/tmp}}}" fi mkdir -p "$dir" 2>/dev/null \ || die "Could not create the install directory. Set SENTRY_INSTALL_DIR to a writable directory, then retry." "download-dir" binary="${dir}/sentry${suffix}.download" blob_file="${dir}/sentry-install-blob-$$" init_binary="${dir}/sentry-install-init-$$${suffix}" trap 'rm -f "$binary" "$blob_file" "$init_binary"' EXIT } # Prints the directory `sentry cli setup` will install into. Keep this in # sync with determineInstallDir in src/lib/binary.ts. setup_install_dir() { if [[ -n "${SENTRY_INSTALL_DIR:-}" ]]; then printf '%s\n' "$SENTRY_INSTALL_DIR" return fi if [[ "${XDG_BIN_HOME:-}" == /* || "${XDG_BIN_HOME:-}" =~ ^[A-Za-z]:[\\/] ]]; then printf '%s\n' "$XDG_BIN_HOME" return fi [[ -n "${HOME:-}" ]] || return 0 local dir for dir in "${HOME}/.local/bin" "${HOME}/bin"; do if [[ -d "$dir" ]] && in_path "$dir"; then printf '%s\n' "$dir" return fi done printf '%s\n' "${HOME}/.local/bin" } # Usage: in_path . Compares PATH entries like samePath: one trailing # slash is ignored, and so is case on macOS and Windows. The subshell keeps # nocasematch local. in_path() ( local entry entries [[ -n "${PATH:-}" ]] || return 1 if [[ "$os" == "darwin" || "$os" == "windows" ]]; then shopt -s nocasematch fi IFS=: read -ra entries <<< "$PATH" for entry in "${entries[@]}"; do if [[ "${#entry}" -gt 1 ]]; then entry="${entry%/}" fi [[ "$entry" == "$1" ]] && return 0 done return 1 ) # `sentry init` runs from a hard link to the downloaded binary, because setup # renames the binary away when it installs it. link_init_binary() { [[ "${SENTRY_INIT:-}" == "1" ]] || return 0 ln -f "$binary" "$init_binary" 2>/dev/null || cp "$binary" "$init_binary" } # --------------------------------------------------------------------------- # Download building blocks # # Each one returns curl's convention for failures: 22 for an HTTP error and # 23 when the file cannot be written. # --------------------------------------------------------------------------- # Usage: download_to . download_to() { curl -fsSL "${curl_retry[@]}" -o "$2" "$1" } # Usage: gzip_intact . gzip_intact() { gunzip -t "$1" 2>/dev/null } # Usage: checksum_matches . A missing checksum or a # missing hash tool counts as a match. A mismatch records the actual hash in # bad_checksum. bad_checksum="" checksum_matches() { [[ -z "$2" ]] && return 0 local actual if command -v sha256sum >/dev/null 2>&1; then actual=$(sha256sum "$1" | awk '{print $1}') || actual="" elif command -v shasum >/dev/null 2>&1; then actual=$(shasum -a 256 "$1" | awk '{print $1}') || actual="" else muted "Warning: sha256sum and shasum are unavailable; skipping checksum verification." >&2 return 0 fi # Callers run this as a condition, where set -e and the ERR trap are off, so # a failing hash tool is checked here. [[ -n "$actual" ]] || die "Failed to compute the SHA-256 checksum of the download" "checksum" [[ "$actual" == "$2" ]] && return 0 bad_checksum="$actual" return 1 } # Usage: download_verified [check]. Downloads to # . Tries once more when the transfer breaks, the checksum does not # match, or rejects the file. Returns 22 or 23 right away, since # another try cannot help, and 1 when both copies are bad. download_verified() { local file=$1 url=$2 sha=$3 check=${4:-} attempt status=0 name # Name the file without the query string: GHCR redirects to a signed URL. name="${url%%\?*}" name="${name##*/}" for attempt in 1 2; do bad_checksum="" if download_to "$url" "$file"; then if checksum_matches "$file" "$sha" && { [[ -z "$check" ]] || "$check" "$file"; }; then return 0 fi status=1 else status=$? rm -f "$file" if [[ "$status" == 22 || "$status" == 23 ]]; then return "$status" fi fi if [[ "$attempt" == 1 ]]; then muted "The download of ${name} was incomplete or corrupt. Downloading it again..." >&2 fi done return "$status" } # Usage: require_download . Dies unless # is 0, with the out-of-space message for 23 and otherwise. require_download() { case "$1" in 0) return 0 ;; 23) die "$no_room_message" "$3" ;; *) die "$2" "$3" ;; esac } # Usage: require_good_checksum . Dies when the last download # did not match its checksum. require_good_checksum() { [[ -z "$bad_checksum" ]] \ || die "Checksum mismatch for ${asset} ${version}: expected $1, got ${bad_checksum}" "checksum" } # Usage: unpack_binary . Unpacks the download to binary, then # deletes the archive. gzip_intact has already checked the archive, so a # failure here means the binary could not be written. unpack_binary() { gunzip -c "$1" > "$binary" || die "$no_room_message" "unpack" rm -f "$1" } # --------------------------------------------------------------------------- # Steps 3 and 4, stable: find the release and download it # # Sentry's release registry is the source of truth for versions, download # URLs, and checksums. When it is down, a pinned version still downloads from # its GitHub release, without checksums; "latest" needs the registry. # --------------------------------------------------------------------------- resolve_stable_release() { local registry_path="latest" if [[ -n "$requested_version" ]]; then version="${requested_version#cli@}" version="${version#v}" [[ "$version" =~ ^[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?$ ]] \ || die "Invalid release version: ${version}" "resolve-version" registry_path="$version" fi if fetch_registry_release "$registry_path"; then return fi if [[ "$registry_status" == "404" && "$registry_path" != "latest" ]]; then die "Unknown Sentry CLI version: ${version}" "resolve-version" fi [[ -n "$version" ]] \ || die "Failed to fetch latest stable version from Sentry's release registry. Retry or install a specific version with --version ." "resolve-version" muted "Could not resolve ${registry_path} from Sentry's release registry. Trying GitHub..." >&2 gz_url="https://github.com/${GITHUB_REPO}/releases/download/cli@${version}/${asset}.gz" raw_url="${gz_url%.gz}" muted "Warning: GitHub fallback downloads are not checksum-verified." >&2 } # Usage: fetch_registry_release . On success, sets version # and the download URLs and checksums. Otherwise sets registry_status (000 # when the registry is unreachable) and fails. fetch_registry_release() { local response metadata registry_version # Read the body from curl's stdout, not a temp file: on some Windows shells, # bash could not read the file that curl had just written. The status code # follows the body on its own line. response=$(curl -sS --max-time 10 "${curl_retry[@]}" -w '\n%{http_code}' \ "${REGISTRY_URL}/$1" 2>/dev/null) || response="000" registry_status="${response##*$'\n'}" [[ "$registry_status" == "200" ]] || return 1 # Asset names, URLs, and checksums contain no whitespace, so stripping it # lets the parsers below treat compact and pretty-printed JSON the same. metadata=$(tr -d ' \t\r\n' <<< "${response%$'\n'*}") registry_version=$(sed -n 's/.*"version":"\([^"]*\)".*/\1/p' <<< "$metadata") # Ignore an answer that is not the release that was asked for. if [[ "$1" == "latest" ]]; then [[ "$registry_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || return 1 else [[ "$registry_version" == "$version" ]] || return 1 fi version="$registry_version" { read -r gz_url; read -r gz_sha; } <<< "$(registry_file "$metadata" "${asset}.gz")" || true { read -r raw_url; read -r raw_sha; } <<< "$(registry_file "$metadata" "$asset")" || true if [[ -z "$gz_url" && -z "$raw_url" ]]; then die "Sentry CLI ${version} has no ${asset} build" "resolve-asset" fi } # Usage: registry_file . Prints the url and then the # sha256 of one entry in the registry's `files` object, one per line (empty # lines when the entry is missing). Expects whitespace-free JSON. registry_file() { awk -v key="\"$2\":{" ' { # Find "":{ and cut out its object by counting braces. i = index($0, key) if (!i) exit s = substr($0, i + length(key) - 1) n = length(s) depth = 0 for (j = 1; j <= n; j++) { c = substr(s, j, 1) if (c == "{") depth++ else if (c == "}" && --depth == 0) break } obj = substr(s, 1, j) url = "" sha = "" if (match(obj, /"url":"https:\/\/[^"]*"/)) url = substr(obj, RSTART + 7, RLENGTH - 8) if (match(obj, /"sha256-hex":"[0-9a-f]+"/)) sha = substr(obj, RSTART + 14, RLENGTH - 15) print url print sha }' <<< "$1" } # Prefers the gzip asset (~37 MB instead of ~99 MB) and falls back to the raw # binary when it is missing or unusable. A checksum mismatch on both tries is # fatal, never a reason to fall back. download_stable() { muted "Downloading sentry v${version}..." if [[ -n "$gz_url" ]] \ && download_verified "$blob_file" "$gz_url" "$gz_sha" gzip_intact; then unpack_binary "$blob_file" return fi require_good_checksum "$gz_sha" [[ -n "$raw_url" ]] || die "Failed to download ${gz_url}" "download" rm -f "$blob_file" local status=0 download_verified "$binary" "$raw_url" "$raw_sha" || status=$? require_good_checksum "$raw_sha" require_download "$status" "Failed to download ${raw_url}" "download" } # --------------------------------------------------------------------------- # Steps 3 and 4, nightly: find the build in GHCR and download it # # Each nightly is an OCI artifact tagged :nightly, with one gzip layer per # platform. There is no jq, so the JSON is read with awk. # --------------------------------------------------------------------------- download_nightly() { muted "Fetching nightly build from GHCR..." local token_response token manifest digest token_response=$(curl -sf "${curl_retry[@]}" \ "https://ghcr.io/token?scope=repository:getsentry/toolkit:pull") \ || die "Failed to get GHCR token" "ghcr-token" token=$(json_field token <<< "$token_response") [[ -n "$token" ]] || die "Failed to get GHCR token" "ghcr-token" manifest=$(curl -sf "${curl_retry[@]}" \ -H "Authorization: Bearer $token" \ -H "Accept: application/vnd.oci.image.manifest.v1+json" \ "https://${GHCR_REPO}/manifests/nightly") \ || die "Failed to fetch nightly manifest from GHCR" "ghcr-manifest" [[ -n "$manifest" ]] || die "Failed to fetch nightly manifest from GHCR" "ghcr-manifest" version=$(json_field version <<< "$manifest") [[ -n "$version" ]] || die "Failed to extract version from nightly manifest" "ghcr-version" muted "Installing nightly sentry ${version}..." digest=$(layer_digest "${asset}.gz" <<< "$manifest") [[ -n "$digest" ]] || die "No nightly build found for ${asset}.gz" "ghcr-digest" download_nightly_blob "$token" "$digest" unpack_binary "$blob_file" } # Usage: json_field . Prints the first string value of in the JSON # on stdin. json_field() { awk -F'"' -v key="$1" '{for(i=1;i<=NF;i++) if($i==key){print $(i+2);exit}}' } # Usage: layer_digest . Prints the digest of the manifest layer # (on stdin) titled . Each layer has "digest" before # "org.opencontainers.image.title", so remember the last digest and print it # when the title matches. layer_digest() { awk -F'"' -v target="$1" '{ for(i=1;i<=NF;i++){ if($i=="digest") d=$(i+2) if($i=="org.opencontainers.image.title"&&$(i+2)==target){print d;exit} } }' } # Usage: download_nightly_blob . Downloads the layer to # blob_file. GHCR usually redirects to Azure Blob Storage, but it can also # return the blob directly with HTTP 200. curl -L would forward the # Authorization header to Azure, which then returns 404, so follow the # redirect by hand without it. download_nightly_blob() { local status=0 http_status redirect_url blob_response="" fetch_ghcr_blob "$1" "$2" "$blob_file" || status=$? require_download "$status" "Failed to fetch nightly blob from GHCR" "ghcr-blob" http_status="${blob_response##*$'\n'}" case "$http_status" in 200) gzip_intact "$blob_file" || die "The nightly blob from GHCR is corrupt" "ghcr-blob" ;; 3??) redirect_url=$(awk '/^[Ll][Oo][Cc][Aa][Tt][Ii][Oo][Nn]:[[:space:]]*/ { sub(/^[^:]*:[[:space:]]*/, ""); sub(/\r$/, ""); print; exit }' <<< "$blob_response") [[ -n "$redirect_url" ]] || die "Failed to get blob redirect URL from GHCR" "ghcr-redirect" status=0 download_verified "$blob_file" "$redirect_url" "" gzip_intact || status=$? require_download "$status" "Failed to download nightly blob" "ghcr-blob" ;; *) die "Failed to fetch nightly blob from GHCR (HTTP ${http_status})" "ghcr-blob" ;; esac } # Usage: fetch_ghcr_blob . Writes the body to # and sets blob_response to the response headers followed by the status # code. Those go to stdout, so only the body needs room on disk. fetch_ghcr_blob() { blob_response=$(curl -sS "${curl_retry[@]}" -D - -o "$3" -w '%{http_code}' \ -H "Authorization: Bearer $1" \ "https://${GHCR_REPO}/blobs/$2") } # --------------------------------------------------------------------------- # Step 5: hand off to the binary # --------------------------------------------------------------------------- # `sentry cli setup --install` places the binary and sets up PATH, # completions, agent skills, and the welcome message. --channel makes later # `sentry cli upgrade` calls track the same channel. run_setup() { local channel="stable" if [[ "$requested_version" == "nightly" ]]; then channel="nightly" fi local args=(--install --method curl --channel "$channel") if $no_modify_path; then args+=(--no-modify-path); fi if $no_completions; then args+=(--no-completions); fi if $no_agent_skills; then args+=(--no-agent-skills); fi # curl | bash leaves stdin on the script pipe. Give setup the controlling # terminal only when both output streams are interactive; setup checks # whether this is a fresh human install before starting login. if [[ -t 1 && -t 2 ]] && { exec 3/dev/null; then "$binary" cli setup "${args[@]}" <&3 3<&- exec 3<&- else "$binary" cli setup "${args[@]}" fi } # errtrace (-E) makes functions and command substitutions inherit the ERR # trap; without it, a failure inside a function exits without a message or a # report. set -E trap 'on_unexpected_failure "$?" "$LINENO" "$BASH_COMMAND" "${FUNCNAME[0]:-}"' ERR main "$@"