equal
deleted
inserted
replaced
9 |
9 |
10 local cmd = "/usr/bin/dict "..word.." 2> /dev/null" |
10 local cmd = "/usr/bin/dict "..word.." 2> /dev/null" |
11 local fh = io.popen(cmd) |
11 local fh = io.popen(cmd) |
12 result = fh:read("*a") -- read dict output |
12 result = fh:read("*a") -- read dict output |
13 fh:close() |
13 fh:close() |
14 if result:match("^$") then return nil, "dict: No output" end |
14 if not result or result:match("^$") then return nil, "dict: No output" end |
15 |
15 |
16 -- Sometimes dict outpur is ugly... Let's filter out whitespace. |
16 -- Sometimes dict outpur is ugly... Let's filter out whitespace. |
17 result = result:gsub("[ \t]+\n", "\n"):gsub("\n\n\n+", "\n\n") |
17 result = result:gsub("[ \t]+\n", "\n"):gsub("\n\n\n+", "\n\n") |
18 -- Trim trailing newlines |
18 -- Trim trailing newlines |
19 result = result:gsub("\n+$", "") |
19 result = result:gsub("\n+$", "") |