# shellcheck shell=dash

# Internal function: Print sorted list of backup files to stdout
# Usage: ___x_cmd_bakman___stdout_files <fp_clean>
# Output: one file path per line, sorted by timestamp
___x_cmd_bakman___stdout_files(){
    local fp_clean="$1"
    local backup_dir="$___X_CMD_BAKMAN_DATA/$fp_clean"

    # Handle zsh nomatch to prevent error on empty glob
    if [ -n "$ZSH_VERSION" ]; then
        (
            set +o nomatch 2>/dev/null || true
            for f in "$backup_dir".*; do
                [ -e "$f" ] || return 0
                printf "%s\n" "$f"
            done 2>/dev/null
        )
    else
        for f in "$backup_dir".*; do
            [ -e "$f" ] || return 0
            printf "%s\n" "$f"
        done 2>/dev/null
    fi
}
