Debian Codegraph @

lookup.sh

raw symbols SCIP
1 #!/bin/bashscip-shell filesystem . . `/bin/bash`.
2 # lookup: Does a dictionary lookup on each word in a data file.
3
4 file=words.data # Data file from which to read words to test.
5
6 echoscip-shell system . . echo.
7 echoscip-shell system . . echo. "Testing file $file"
8 echoscip-shell system . . echo.
9
10 while [scip-shell system . . `[`. "$word" != end ] # Last word in data file.
11 do # ^^^
12 read word # From data file, because of redirection at end of loop.
13 lookscip-shell system . . look. $word > /dev/nullscip-shell filesystem . . `/dev/null`. # Don't want to display lines in dictionary file.
14 # Searches for words in the file /usr/share/dict/words
15 #+ (usually a link to linux.words).
16 lookup=$? # Exit status of 'look' command.
17
18 if [scip-shell system . . `[`. "$lookup" -eq 0 ]
19 then
20 echoscip-shell system . . echo. "\"$word\" is valid."
21 else
22 echoscip-shell system . . echo. "\"$word\" is invalid."
23 fi
24
25 done <"$file" # Redirects stdin to $file, so "reads" come from there.
26
27 echoscip-shell system . . echo.
28
29 exit 0
30
31 # ----------------------------------------------------------------
32 # Code below line will not execute because of "exit" command above.
33
34
35 # Stephane Chazelas proposes the following, more concise alternative:
36
37 while read word && [[ $word != end ]]
38 do if lookscip-shell system . . look. "$word" > /dev/nullscip-shell filesystem . . `/dev/null`.
39 then echoscip-shell system . . echo. "\"$word\" is valid."
40 else echoscip-shell system . . echo. "\"$word\" is invalid."
41 fi
42 done <"$file"
43
44 exit 0