# shellcheck shell=dash

# command powershell.exe -Command "start /C www.bing.com"

___x_cmd_open___main(){
    xrc pwsh
    # for i in "$@"; do
    #     case "$i" in
    #         -f|-i|-n|-v)    continue ;;
    #         -*)             continue ;;
    #         # /|/bin)        printf "Abort because trying to remove key file." >&2 || return 1 ;;
    #     esac
    # done

    # TODO: handle the arguments well.

    # In windows, the default home path is a problem ...
    local p="${1:-$PWD}"

    [ ! -e "$p" ] || {
        [ -z "$___X_CMD_BOX_INNER_HOME" ]           ||  \
        [ "$HOME" = "$___X_CMD_BOX_INNER_HOME" ]    ||  \
        [ "${p#"${___X_CMD_BOX_INNER_HOME}"}" = "$p" ] || p="${HOME}${p#"$___X_CMD_BOX_INNER_HOME"}"
    }

    local x_=; ___x_cmd_pwsh_path___linux_to_win_ "$p"
    [ -n "$x_" ] ||  N=open M="Not found path ==> $1" log:ret:64
    ___x_cmd_cmds powershell.exe -Command "start $x_"
}
