Skip to content

Instantly share code, notes, and snippets.

@jordanwade90
Last active January 1, 2016 21:39
Show Gist options
  • Save jordanwade90/8204963 to your computer and use it in GitHub Desktop.
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.
#!/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