chiark
/
gitweb
/
~cjwatson
/
bin.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
| inline |
side by side
isttyutf8: New script to guess whether a terminal speaks UTF-8. Still eats
[bin.git]
/
isttyutf8
diff --git a/isttyutf8
b/isttyutf8
new file mode 100755
(executable)
index 0000000..
2b3d9b9
--- /dev/null
+++ b/
isttyutf8
@@ -0,0
+1,12
@@
+#! /bin/sh
+set -e
+
+[ -t 0 ] || exit 1
+
+# TODO: eats pending keystrokes somehow.
+result="$(ctlseq -r -R CR "$(printf '\xc3\xb6')" CSI 6 n CR SP SP CR)"
+if expr "$result" : '.\+;2R' >/dev/null; then
+ exit 0
+else
+ exit 1
+fi