From 3ec6c18c81853b52ff9dbc9ecccc890a9534322c Mon Sep 17 00:00:00 2001 From: bptato Date: Wed, 22 May 2024 16:43:58 +0200 Subject: man: quote keyword & section --- adapter/protocol/man.nim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'adapter/protocol/man.nim') diff --git a/adapter/protocol/man.nim b/adapter/protocol/man.nim index 6a6acf04..a5b7dab9 100644 --- a/adapter/protocol/man.nim +++ b/adapter/protocol/man.nim @@ -275,9 +275,9 @@ proc myOpen(cmd: string): tuple[ofile, efile: File] = return (ofile, efile) proc doMan(man, keyword, section: string) = - let sectionOpt = if section == "": "" else: ' ' & section + let sectionOpt = if section == "": "" else: ' ' & quoteShellPosix(section) let cmd = "MANCOLOR=1 GROFF_NO_SGR=1 MAN_KEEP_FORMATTING=1 " & - man & sectionOpt & ' ' & keyword + man & sectionOpt & ' ' & quoteShellPosix(keyword) let (ofile, efile) = myOpen(cmd) if ofile == nil: stdout.write("Cha-Control: ConnectionError 1 failed to run " & cmd) @@ -294,7 +294,7 @@ proc doLocal(man, path: string) = # Note: we intentionally do not use -l, because it is not supported on # various systems (at the very least FreeBSD, NetBSD). let cmd = "MANCOLOR=1 GROFF_NO_SGR=1 MAN_KEEP_FORMATTING=1 " & - man & ' ' & path + man & ' ' & quoteShellPosix(path) let (ofile, efile) = myOpen(cmd) if ofile == nil: stdout.write("Cha-Control: ConnectionError 1 failed to run " & cmd) @@ -305,8 +305,8 @@ proc doLocal(man, path: string) =
""", keyword = path.afterLast('/').until('.'))
 
 proc doKeyword(man, keyword, section: string) =
-  let sectionOpt = if section == "": "" else: " -s " & section
-  let cmd = man & sectionOpt & " -k " & keyword
+  let sectionOpt = if section == "": "" else: " -s " & quoteShellPosix(section)
+  let cmd = man & sectionOpt & " -k " & quoteShellPosix(keyword)
   let (ofile, efile) = myOpen(cmd)
   if ofile == nil:
     stdout.write("Cha-Control: ConnectionError 1 failed to run " & cmd)
-- 
cgit 1.4.1-2-gfad0