FIX: Add source guards to library files to prevent re-sourcing
php-analyzer.sh and php-calculator-improved.sh were trying to re-source dependencies when sourced from other scripts, causing 'not found' errors. Added: - _PHP_ANALYZER_LOADED source guard - _PHP_CALCULATOR_LOADED source guard - Conditional checks for dependency sourcing - Prevents double-sourcing of php-detector.sh and system-detect.sh
This commit is contained in:
+16
-4
@@ -3,10 +3,22 @@
|
||||
# Part of Server Toolkit - Phase 2: Analysis
|
||||
# Dependencies: lib/php-detector.sh, lib/system-detect.sh
|
||||
|
||||
# Source required libraries
|
||||
_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$_LIB_DIR/php-detector.sh" 2>/dev/null || { echo "ERROR: php-detector.sh not found"; return 1; }
|
||||
source "$_LIB_DIR/system-detect.sh" 2>/dev/null || { echo "ERROR: system-detect.sh not found"; return 1; }
|
||||
# Source guard - prevent re-sourcing (but allow re-initialization if needed)
|
||||
if [ -n "${_PHP_ANALYZER_LOADED:-}" ]; then
|
||||
return 0
|
||||
fi
|
||||
readonly _PHP_ANALYZER_LOADED=1
|
||||
|
||||
# Source required libraries only if not already loaded
|
||||
if [ -z "${_PHP_DETECTOR_LOADED:-}" ]; then
|
||||
_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$_LIB_DIR/php-detector.sh" 2>/dev/null || { echo "ERROR: php-detector.sh not found"; return 1; }
|
||||
fi
|
||||
|
||||
if [ -z "${_SYSTEM_DETECT_LOADED:-}" ]; then
|
||||
_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "$_LIB_DIR/system-detect.sh" 2>/dev/null || { echo "ERROR: system-detect.sh not found"; return 1; }
|
||||
fi
|
||||
|
||||
# ============================================================================
|
||||
# HELPER FUNCTIONS - PURE BASH OPTIMIZATIONS
|
||||
|
||||
Reference in New Issue
Block a user