From 5a1318bbf2e5847af726d9d695d29eb4eb18399b Mon Sep 17 00:00:00 2001 From: MasterDraco Date: Fri, 7 Mar 2025 11:43:28 +0000 Subject: [PATCH] Fix syntax errors in utils-module.sh MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed multiple syntax errors in utils-module.sh: - Replaced compound commands with syntax with clearer if statements - This addresses issues with bash syntax in older versions of bash - Improved error handling with explicit 2 checks 💡 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- modules/utils-module.sh | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/modules/utils-module.sh b/modules/utils-module.sh index 4b17e23..b61ce52 100644 --- a/modules/utils-module.sh +++ b/modules/utils-module.sh @@ -104,19 +104,21 @@ function ensure_npm_packages() { # First ensure the installation directory exists if [ ! -d "$install_dir" ]; then log "INFO" "Creating installation directory: $install_dir" - mkdir -p "$install_dir" || { + mkdir -p "$install_dir" + if [ $? -ne 0 ]; then log "ERROR" "Failed to create installation directory: $install_dir" return 1 - } - } + fi + fi # Ensure data directory exists if [ ! -d "$install_dir/data" ]; then log "INFO" "Creating data directory: $install_dir/data" - mkdir -p "$install_dir/data" || { + mkdir -p "$install_dir/data" + if [ $? -ne 0 ]; then log "ERROR" "Failed to create data directory: $install_dir/data" return 1 - } + fi # Initialize empty data files echo "[]" > "$install_dir/data/rss-feeds.json" @@ -127,10 +129,11 @@ function ensure_npm_packages() { # Ensure package.json exists in the installation directory if [ ! -f "$install_dir/package.json" ]; then log "INFO" "Copying package.json to installation directory..." - cp "$SCRIPT_DIR/package.json" "$install_dir/package.json" || { + cp "$SCRIPT_DIR/package.json" "$install_dir/package.json" + if [ $? -ne 0 ]; then log "ERROR" "Failed to copy package.json to installation directory" return 1 - } + fi fi # Install NPM packages if not already installed or if it's an update @@ -141,16 +144,18 @@ function ensure_npm_packages() { local current_dir=$(pwd) # Change to install directory and install packages - cd "$install_dir" || { + cd "$install_dir" + if [ $? -ne 0 ]; then log "ERROR" "Failed to change to installation directory: $install_dir" return 1 - } + fi - npm install || { + npm install + if [ $? -ne 0 ]; then log "ERROR" "NPM installation failed in $install_dir" cd "$current_dir" # Return to original directory return 1 - } + fi # Return to original directory cd "$current_dir"