From: Sami Kerola Date: Sat, 12 Aug 2017 08:31:11 +0000 (+0100) Subject: look: use WORDLIST environment variable to find word list X-Git-Tag: v2.31-rc1~129 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a653878c45cd533abbd4950b2fb5ea8c6cef6395;p=thirdparty%2Futil-linux.git look: use WORDLIST environment variable to find word list 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 --- diff --git a/misc-utils/look.1 b/misc-utils/look.1 index 503e385841..cca83416ec 100644 --- a/misc-utils/look.1 +++ b/misc-utils/look.1 @@ -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 diff --git a/misc-utils/look.c b/misc-utils/look.c index 60fbbbfca1..d2699bfdd6 100644 --- a/misc-utils/look.c +++ b/misc-utils/look.c @@ -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 */