aboutsummaryrefslogtreecommitdiffstats
path: root/fch
diff options
context:
space:
mode:
authorSam Anthony <sam@samanthony.xyz>2024-09-01 11:48:11 -0400
committerSam Anthony <sam@samanthony.xyz>2024-09-01 11:48:11 -0400
commited48f10d093b16919217bcf70f02393a78b0e567 (patch)
tree72c7b66e8b90c74452a8a157ed83d05fe3f03a80 /fch
parent05c2582f45f9253575d2163936c836addae0f7af (diff)
downloadbin-ed48f10d093b16919217bcf70f02393a78b0e567.zip
fch: find plan9port directory in environment
Diffstat (limited to 'fch')
-rwxr-xr-xfch17
1 files changed, 14 insertions, 3 deletions
diff --git a/fch b/fch
index 361dea0..f51b125 100755
--- a/fch
+++ b/fch
@@ -1,22 +1,33 @@
#!/usr/bin/awk -f
# fch: find a unicode character
-# Requires plan9port to be installed at /opt/plan9
+# Requires plan9port to be installed at $PLAN9
BEGIN {
if (ARGC < 2) {
print "Usage: fch <charname>"
exit 2
}
-
charname = ARGV[1]
for (i = 2; i < ARGC; i++)
charname = charname" "ARGV[i];
- while (getline <"/opt/plan9/lib/unicode")
+ root = ENVIRON["PLAN9"]
+ if (length(root) <= 0) {
+ print "fch: $PLAN9 not set"
+ exit 1
+ }
+ table = root"/lib/unicode"
+
+ while ((err = getline <table) > 0) {
if (match($0, charname)) {
desc = substr($0, length($1)+1, length($0))
"9 unicode " $1 | getline char; close(char)
printf "%s%s\n",char,desc
}
+ }
+ if (err < 0) { # getline failed
+ print "fch: failed to read from " table
+ exit 1
+ }
}