#!/bin/bash ################################################################################ # fix-filter-variables.sh # Script to fix FILTER variable mismatches in build scripts # # This script updates all the build scripts that have incorrect FILTER values # to use the correct pattern based on their filename variant. ################################################################################ # Get the directory of the current script SCRIPT_DIR="$(dirname "$(realpath "$0")")" # Determine the project root directory PROJECT_ROOT="$(dirname "$SCRIPT_DIR")" # Source the config source "${PROJECT_ROOT}/core/config.sh" # Define the scripts that need FILTER fixes and their correct values declare -A FILTER_FIXES=( ["${ROMGROOMERDIR}/build-snes-eng-1g1r.sh"]="eng.1g1r" ["${ROMGROOMERDIR}/build-snes-all-1g1r.sh"]="all.1g1r" ["${ROMGROOMERDIR}/build-atari7800-all-1g1r.sh"]="all.1g1r" ["${ROMGROOMERDIR}/build-atari5200-all-1g1r.sh"]="all.1g1r" ["${ROMGROOMERDIR}/build-gamegear-all-1g1r.sh"]="all.1g1r" ["${ROMGROOMERDIR}/build-gamegear-eng-1g1r.sh"]="eng.1g1r" ["${ROMGROOMERDIR}/build-sega32x-all-1g1r.sh"]="all.1g1r" ["${ROMGROOMERDIR}/build-sega32x-eng-1g1r.sh"]="eng.1g1r" ["${ROMGROOMERDIR}/build-nds-all-1g1r.sh"]="all.1g1r" ["${ROMGROOMERDIR}/build-nds-eng-1g1r.sh"]="eng.1g1r" ) echo "Fixing FILTER variables in build scripts..." for script_path in "${!FILTER_FIXES[@]}"; do if [[ -f "$script_path" ]]; then script_name=$(basename "$script_path") correct_filter="${FILTER_FIXES[$script_path]}" echo " Fixing $script_name: FILTER=$correct_filter" # Update the FILTER variable in the script sed -i "s/FILTER=\"[^\"]*\"/FILTER=\"$correct_filter\"/" "$script_path" if [[ $? -eq 0 ]]; then echo " ✓ Updated successfully" else echo " ✗ Failed to update" fi else echo " ✗ Script not found: $script_path" fi done echo "FILTER variable fixes completed."