#!/bin/bash

replaceBcryptPasswords() 
{
    local file="$1"
    local app_name
    app_name=$(basename "$(dirname "$file")")

    # Only scan for bcrypt placeholders that actually exist in the file
    local existing_placeholders=$(runInstallOp grep -oE 'RANDOMIZEDBCRYPTPASSWORD[0-9]*' "$file" 2>/dev/null | sort -u)
    
    if [[ -n "$existing_placeholders" ]]; then
        while IFS= read -r placeholder; do
            if [[ -n "$placeholder" ]]; then
                processBcryptPassword "$app_name" "$file" "$placeholder"
            fi
        done <<< "$existing_placeholders"
    fi
}
