# shellcheck shell=dash

___x_cmd_boot_initrootbin(){
    boot:info "Update the x-cmd root bin"
    # ___x_cmd_boot___prepare "$___X_CMD_ROOT_MOD/x-cmd/lib/bin/x"                    "$___X_CMD_ROOT/bin/x"
    # ___x_cmd_boot___prepare "$___X_CMD_ROOT_MOD/x-cmd/lib/bin/xbin"                 "$___X_CMD_ROOT/bin/xbin"
    # ___x_cmd_boot___prepare "$___X_CMD_ROOT_MOD/x-cmd/lib/bin/xbinexp"              "$___X_CMD_ROOT/bin/xbinexp"
    ___x_cmd_boot___prepare "$___X_CMD_ROOT_MOD/x-cmd/lib/bin/x-cmd"                "$___X_CMD_ROOT/bin/x-cmd"

    ___x_cmd_boot___prepare "$___X_CMD_ROOT_MOD/x-cmd/lib/bin/___x_cmdexe"          "$___X_CMD_ROOT/bin/___x_cmdexe"
    ___x_cmd_boot___prepare "$___X_CMD_ROOT_MOD/x-cmd/lib/bin/___x_cmdexe_exp"      "$___X_CMD_ROOT/bin/___x_cmdexe_exp"

    ___x_cmd os is win || return 0
    # ___x_cmd_boot___prepare "$___X_CMD_ROOT_MOD/x-cmd/lib/bin/xbinexp.bat"          "$___X_CMD_ROOT/bin/xbinexp.bat"
    ___x_cmd_boot___prepare "$___X_CMD_ROOT_MOD/x-cmd/lib/bin/___x_cmdexe.bat"      "$___X_CMD_ROOT/bin/___x_cmdexe.bat"
    ___x_cmd_boot___prepare "$___X_CMD_ROOT_MOD/x-cmd/lib/bin/___x_cmdexe_exp.bat"  "$___X_CMD_ROOT/bin/___x_cmdexe_exp.bat"

    ___x_cmd_cmds unix2dos  "$___X_CMD_ROOT/bin/"*.bat
}

___x_cmd_boot___prepare(){
    local srcfp="$1"
    local tgtfp="$2"
    [ -f "$srcfp" ] || return $?
    ___x_cmd ensurefp "$tgtfp"
    [ ! -f "$tgtfp" ] || ___x_cmd_cmds rm "$tgtfp"
    ___x_cmd_cmds cp "$srcfp" "$tgtfp"
    ___x_cmd_cmds chmod +x "$tgtfp"
}

