1#!/usr/bin/env -S porch -f 2-- 3-- Copyright (c) 2024 Kyle Evans <kevans@FreeBSD.org> 4-- 5-- SPDX-License-Identifier: BSD-2-Clause 6-- 7 8timeout(3) 9 10local function spawn_one(...) 11 spawn(...) 12 13 stty("lflag", 0, tty.lflag.ICANON) 14end 15 16-- We can send one byte... 17spawn_one("readsz", "-c", 1) 18write "H" 19match "^H$" 20 21-- or many. 22spawn_one("readsz", "-c", 1) 23write "Hello" 24match "^Hello$" 25 26-- VEOF is a normal character here, passed through as-is. 27spawn_one("readsz", "-c", 1) 28write "Hello^D" 29match "^Hello\x04$" 30spawn_one("readsz", "-c", 1) 31write "^D" 32match "^\x04$" 33 34-- Confirm that FIONREAD agrees that VEOF will be returned, even if it was sent 35-- while the tty was still in canonical mode. 36spawn("fionread") 37write "^D" 38stty("lflag", 0, tty.lflag.ICANON) 39match "^1$" 40