Last active
January 1, 2016 21:39
-
-
Save jordanwade90/8204963 to your computer and use it in GitHub Desktop.
Searches plan9port’s Unicode character database and prints any matches along with their corresponding character.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/plan9/bin/rc | |
opt=() | |
while(~ $1 -* && ! ~ $1 --){ | |
opt=($opt $1) | |
shift | |
} | |
if(~ $1 --){ | |
shift | |
opt=($opt -e) | |
} | |
if(~ $#* 0) { | |
echo usage: $0 [options...] [--] [words...] >/dev/stderr | |
echo Searches $PLAN9^/lib/unicode for words and prints any matches along with their corresponding character. Options are passed to grep. If you need a word to begin with a dash, -- will stop option processing and treat the remaining arguments as words. | fmt >/dev/stderr | |
exit 'no words' | |
} | |
fn unisearch{ grep $* $PLAN9/lib/unicode } | |
if(unisearch $opt $"* >/dev/null) { | |
# ssam command removes the blank line from 000a line feed | |
paste <{unicode `{unisearch $opt $"* | awk '{print $1}'} | ssam -e 's/\n\n/\n/'} <{unisearch $opt $"*} | |
} | |
if not { | |
echo no match >/dev/stderr | |
exit 'no match' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment