Skip to content

Commit

Permalink
look: use WORDLIST environment variable to find word list
Browse files Browse the repository at this point in the history
The WORDLIST is the same hunspell(1) and ispell(1) uses to achieve the same.
Apparently aspell(1) does not work with files like traditional dict lists.

Reference: https://github.com/hunspell/hunspell/blob/master/man/hunspell.1#L388
Reference: http://www.skrenta.com/rt/man/ispell.1.html
Reference: http://aspell.net/man-html/Creating-an-Individual-Word-List.html#Creating-an-Individual-Word-List
Signed-off-by: Sami Kerola <[email protected]>
  • Loading branch information
kerolasa authored and karelzak committed Aug 21, 2017
1 parent 6047c6d commit a653878
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions misc-utils/look.1
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ sort -d /etc/passwd -o /tmp/look.dict
look -t: root:foobar /tmp/look.dict
.nf
.RE
.SH ENVIRONMENT
.TP
.B WORDLIST
Path to a dictionary file. The environment variable has greater priority
than the dictionary path defined in FILES segment.
.SH FILES
.IP "\fB/usr/share/dict/words\fR" 4
the dictionary
Expand Down
6 changes: 5 additions & 1 deletion misc-utils/look.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ main(int argc, char *argv[])

setlocale(LC_ALL, "");

file = _PATH_WORDS;
if ((file = getenv("WORDLIST")) && !access(file, R_OK))
/* use the WORDLIST */;
else
file = _PATH_WORDS;

termchar = '\0';
string = NULL; /* just for gcc */

Expand Down

0 comments on commit a653878

Please sign in to comment.