-- let path = system(s:man_cmd.' '.s:man_find_arg.' '.shellescape(a:name))
-+ let path = system(s:man_cmd.' '.s:man_find_arg.' '.shellescape(a:name).'| head -n 1')
- if path !~# '^\/'
- throw 'no manual entry for '.a:name
- endif
-@@ -123,7 +123,7 @@
- " - sections starting with '-'
- " - 3pcap section (found on macOS)
- " - commas between sections (for section priority)
-- return system(s:man_cmd.' '.s:man_find_arg.' -s '.shellescape(a:sect).' '.shellescape(a:name))
-+ return system(s:man_cmd.' '.s:man_find_arg.' -s '.shellescape(a:sect).' '.shellescape(a:name).'| head -n 1')
- endfunction
-
- function! s:verify_exists(sect, name) abort
+- return s:system(['man', s:find_arg, a:name])
++ " Take the first one if multiple lines returned, such as when
++ " both man1p/test.1p and man1/test.1 exists.
++ return split(s:system(['man', s:find_arg, a:name]), "\n")[0] . "\n"
+ endif
+ " '-s' flag handles:
+ " - tokens like 'printf(echo)'