-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlib.sh
More file actions
57 lines (51 loc) · 1.72 KB
/
lib.sh
File metadata and controls
57 lines (51 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# lib.sh - Common utility functions for pgxntool scripts
#
# This file is meant to be sourced by other scripts, not executed directly.
# Usage: source "$(dirname "${BASH_SOURCE[0]}")/lib.sh"
# =============================================================================
# SETUP FILES CONFIGURATION
# =============================================================================
# Files copied by setup.sh and tracked by update-setup-files.sh for sync updates.
# Format: "source_in_pgxntool:destination_in_project"
# =============================================================================
SETUP_FILES=(
"_.gitignore:.gitignore"
"test/deps.sql:test/deps.sql"
)
# Symlinks created by setup.sh and verified by update-setup-files.sh
# Format: "destination:target"
SETUP_SYMLINKS=(
"test/pgxntool:../pgxntool/test/pgxntool"
)
# Error function - outputs to stderr but doesn't exit
# Usage: error "message"
error() {
echo "ERROR: $*" >&2
}
# Die function - outputs error message and exits with specified code
# Usage: die EXIT_CODE "message"
die() {
local exit_code=$1
shift
error "$@"
exit $exit_code
}
# Debug function
# Usage: debug LEVEL "message"
# Outputs message to stderr if DEBUG >= LEVEL
# Debug levels use multiples of 10 (10, 20, 30, 40, etc.) to allow for easy expansion
# - 10: Critical errors, important warnings
# - 20: Warnings, significant state changes
# - 30: General debugging, function entry/exit, array operations
# - 40: Verbose details, loop iterations
# - 50+: Maximum verbosity
# Enable with: DEBUG=30 scriptname.sh
debug() {
local level=$1
shift
local message="$*"
if [ "${DEBUG:-0}" -ge "$level" ]; then
echo "DEBUG[$level]: $message" >&2
fi
}