OILS / spec / stateful / read-n-demo.sh View on Github | oilshell.org

25 lines, 17 significant
1#!/usr/bin/env bash
2set -euo pipefail
3
4read-one () {
5 # try typing a letter without hitting newline
6 # the shell should respond immediately
7 read -n 1
8 echo
9 echo "$REPLY"
10}
11
12read-multiple () {
13 read -n 5
14 echo
15 echo "$REPLY"
16}
17
18all () {
19 echo "one char:"
20 read-one
21 echo "multiple chars:"
22 read-multiple
23}
24
25"$@"