-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathusv-to-debug.bash
More file actions
executable file
·41 lines (38 loc) · 976 Bytes
/
usv-to-debug.bash
File metadata and controls
executable file
·41 lines (38 loc) · 976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env bash
set -euf -o pipefail
# USV example shell script that demonstrates the use of USV characters.
# This script reads STDIN one character at a time, and prints text.
escape=false
while IFS= read -N1 -r c; do
if [ "$escape" = true ]; then
escape=false
printf %s "\nescape character: " "$c"
else
case "$c" in
"\u001B" | "␛")
printf "\nescape\n"
escape=true
;;
"\u001F" | "␟")
printf "\nunit separator\n"
;;
"\u001E" | "␞")
printf "\nrecord separator\n"
;;
"\u001D" | "␝")
printf "\ngroup separator\n"
;;
"\u001C" | "␜")
printf "\nfile separator\n"
;;
"\u0004" | "␄")
printf "\nend of transmission\n"
break
;;
*)
printf %s "$c"
;;
esac
fi
done
printf "\n"