
trap 'stty -raw 2>/dev/null' EXIT
stty raw 2>/dev/null

trap "printf '\003\n'" INT

while true; do
    if read -rsk 1 ch; then
        [ "$ch" != "$___X_CMD_UNSEENCHAR_NEWLINE" ] || ch=""
        printf "%s\n" "$ch"
    else
        # ctrl c
        printf "%s\n" "$___X_CMD_UNSEENCHAR_003"
    fi
done 2>/dev/null

stty -raw 2>/dev/null
