#!/bin/rc temp=/tmp/dict-$pid action=check fn init{ lang=$* dict=/lib/words.$"* lodict=`{basename $dict} } fn usage{ echo 'usage: spell [ -l de | en ] [ -a word ... | -i ] [ file ... ]' >[1=2] exit 'usage' } fn lower{ switch($lang){ case de tr A-ZÄÖÜ a-zäöü case * tr A-Z a-z } } fn words{ switch ($lang){ case de tr -c 'a-zA-ZäöüÄÖÜß''' ' ' | sort | uniq case * tr -c 'a-zA-Z''' ' ' | sort | uniq } } fn check{ if(test -f $lodict) dict=$lodict for(word in `{deroff $* | words | comm -13 $dict -}) # Matching case insensitive to avoid more entries. if(! grep -is '^'$word'$' $dict) echo $word } init en while(~ $1 -*){ switch($1) { case -l init $2 shift 2 case -a action=add shift wordlist=$* shift $#* case -i action=init shift case -* usage } } switch($action){ case add if(test -f $lodict) dict=$lodict for(word in $wordlist) echo $word >>$dict words <$dict >$temp && mv $temp $dict case check check $* case init comm -12 <{deroff $* | words} $dict >>$lodict for(word in `{deroff $* | words | comm -13 $lodict -}) if(grep -si '^'$word'$' $dict) echo $word >>$lodict words <$lodict >$temp && mv $temp $lodict case * usage }