From: Nicolas Boisselier Date: Mon, 15 Apr 2024 09:44:33 +0000 (+0200) Subject: etc/profile.d/functions X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=d6b12840d6ed56891c6f7a2c9586949efa10da8e;p=nb.git etc/profile.d/functions --- diff --git a/etc/profile.d/functions b/etc/profile.d/functions index 63c2e68a..b11a5bf8 100755 --- a/etc/profile.d/functions +++ b/etc/profile.d/functions @@ -7,6 +7,23 @@ type -P which > /dev/null || which() { type -P "$1" 2>&1; } +echo_stty() { + usage="echo_stty DEVICE [BAUD=9600]" + local dev="${1?$usage}" + local str="${2?$usage}" + local baud="${3:-9600}" + + (cat "$dev" > /dev/null &) >/dev/null 2>&1 + local pid=$! + + stty "$baud" -F "$dev" raw -echo + echo "$str" > "$dev" + + kill "$pid" >/dev/null 2>&1 + + return 0 +} + cat_stty() { usage="cat_stty DEVICE [BAUD=9600]" local dev="${1?$usage}"