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:
+13
-1
@@ -3,10 +3,22 @@
|
|||||||
# Part of Server Toolkit - Phase 2: Analysis
|
# Part of Server Toolkit - Phase 2: Analysis
|
||||||
# Dependencies: lib/php-detector.sh, lib/system-detect.sh
|
# Dependencies: lib/php-detector.sh, lib/system-detect.sh
|
||||||
|
|
||||||
# Source required libraries
|
# 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)"
|
_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/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; }
|
source "$_LIB_DIR/system-detect.sh" 2>/dev/null || { echo "ERROR: system-detect.sh not found"; return 1; }
|
||||||
|
fi
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# HELPER FUNCTIONS - PURE BASH OPTIMIZATIONS
|
# HELPER FUNCTIONS - PURE BASH OPTIMIZATIONS
|
||||||
|
|||||||
@@ -9,10 +9,22 @@
|
|||||||
# - Safe allocation buffers based on traffic stability
|
# - Safe allocation buffers based on traffic stability
|
||||||
################################################################################
|
################################################################################
|
||||||
|
|
||||||
# Dependencies
|
# Source guard - prevent re-sourcing
|
||||||
|
if [ -n "${_PHP_CALCULATOR_LOADED:-}" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
readonly _PHP_CALCULATOR_LOADED=1
|
||||||
|
|
||||||
|
# Dependencies - only source if not already loaded
|
||||||
|
if [ -z "${_PHP_DETECTOR_LOADED:-}" ]; then
|
||||||
_LIB_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
_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/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; }
|
source "$_LIB_DIR/system-detect.sh" 2>/dev/null || { echo "ERROR: system-detect.sh not found"; return 1; }
|
||||||
|
fi
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# HELPER FUNCTION - Extract field from pipe-delimited string
|
# HELPER FUNCTION - Extract field from pipe-delimited string
|
||||||
|
|||||||
Reference in New Issue
Block a user