# shellcheck shell=dash

# ___x_cmd_run_by_file
___x_cmd_solo_engine_run(){
    local filepath="${1:?filepath}"; shift
    x:debug "exec: ___x_cmd_solo_engine_run: $filepath"

    if [ -L "$filepath" ]; then
        filepath="$(___x_cmd readlink_recursive "$filepath")"
        filepath="$(___x_cmd_abspath "$filepath")"
    fi

    local x_
    if ___x_cmd_solo___detect_ "$filepath"; then
        x:debug "Detect file=$filepath to be run by $x_"
        ___x_cmd_solo_engine_runmain "$x_" "$filepath" "$@"
    else
        x:debug "Fail to detect file. File will be run with source: $filepath"
        # [ ! -f "$filepath" ] || ___x_cmd_cmds_cat "$filepath"
        ___x_cmd_solo_engine_runmain source "$filepath" "$@"
    fi
}


# ___x_cmd___xrc_run
___x_cmd_solo_engine___run_xrc(){
    local fp="${1:?filepath}"; shift

    local ___X_CMD_XRC_SOURCE_FILE_MAIN_=
    ___x_cmd_xrc_source_file_main_ "$fp" || return 1

    "$___X_CMD_XRC_SOURCE_FILE_MAIN_" "$@"
}

# ___x_cmd___source_run
___x_cmd_solo_engine___run_source(){
    local ___x_cmd_x_source_run_filepath="${1:?filepath}";        shift
    . "$___x_cmd_x_source_run_filepath" "$@"
}
