
___x_cmd_uhb_host_gen(){
    local ip="$1"
    [ -n "$ip" ] || {
        if ___x_cmd os is win; then ip=127.0.0.1
        else                        ip=0.0.0.0
        fi
    }

    ___x_cmd is ip "$ip" || N=uhb M="Invalid ip provided -> $ip" log:ret:64

    if [ -f /etc/hosts ]; then
        ___x_cmd_uhb_vanilla </etc/hosts
    fi

    printf "%s\n" "# x-cmd: Lines below managed by x-cmd. Don't edit manually."

    ___x_cmd_uhb_host ls | \
        ___x_cmd_cmds awk -v "ip=$ip" \
        '{ printf("%s %s\n", ip, $0); }'
}


# backup then copy ...
___x_cmd_uhb_host_cleanup(){
    local fp="$___X_CMD_ROOT_TMP/uhb/hosts/tmp"
    ___x_cmd ensurefp "$fp"

    if [ -f /etc/hosts ]; then
        ___x_cmd_uhb_vanilla </etc/hosts >"$fp"
    fi

    ___x_cmd sudo cp "$fp" /etc/hosts
}

