aboutsummaryrefslogtreecommitdiff
path: root/openrussian.lua
diff options
context:
space:
mode:
authorRobin Haberkorn <robin.haberkorn@googlemail.com>2024-01-12 17:42:44 +0300
committerRobin Haberkorn <robin.haberkorn@googlemail.com>2024-01-12 17:42:44 +0300
commit0fbed9a95255c9a6ade511bf3c12286f4450fa90 (patch)
tree33d506f22df736c1197b4354d9b8be28baf37b3a /openrussian.lua
parent03777f5be657dcaa8fe379f2e1a39d1c2db04d00 (diff)
downloadopenrussian-cli-0fbed9a95255c9a6ade511bf3c12286f4450fa90.tar.gz
support FreeBSD
* Instead of relying on `man -`, we call Groff directly. * Naturally, we must depend on Groff as well. * man-db is not available on FreeBSD
Diffstat (limited to 'openrussian.lua')
-rwxr-xr-xopenrussian.lua9
1 files changed, 8 insertions, 1 deletions
diff --git a/openrussian.lua b/openrussian.lua
index 961efdc..6ee5628 100755
--- a/openrussian.lua
+++ b/openrussian.lua
@@ -600,7 +600,14 @@ end
-- Open stream only now, after no more messages have to be written to
-- stdout/stderr.
-out_stream = assert(use_stdout and io.stdout or io.popen("man /dev/stdin", "w"))
+if use_stdout then
+ out_stream = io.stdout
+else
+ local size_stream = io.popen("stty size")
+ local columns = size_stream and size_stream:read("*a"):match("%d+ (%d+)") or 80
+ out_stream = io.popen("nroff -Kutf8 -Tutf8 -t -man -rLL="..columns.."n -rLT="..columns.."n | less -r", "w")
+end
+assert(out_stream)
-- NOTE: The headers and footers shouldn't contain critical information
-- since they might not be printed at all.