From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from localhost (mandoc.bsd.lv [local]) by mandoc.bsd.lv (OpenSMTPD) with ESMTPA id b63d299f for ; Mon, 10 Feb 2020 08:49:45 -0500 (EST) Date: Mon, 10 Feb 2020 08:49:45 -0500 (EST) X-Mailinglist: mandoc-source Reply-To: source@mandoc.bsd.lv MIME-Version: 1.0 From: schwarze@mandoc.bsd.lv To: source@mandoc.bsd.lv Subject: mandoc: For compatibility with the man(1) implementations of the man-1.6 X-Mailer: activitymail 1.26, http://search.cpan.org/dist/activitymail/ Content-Type: text/plain; charset=utf-8 Message-ID: Log Message: ----------- For compatibility with the man(1) implementations of the man-1.6 and man-db packages, print the manpath if the -w option is given without a following name argument. This quirk has been in man-1.6 since at least man-1.5e (1998) and in man-db since 2012. Using this feature in portable software is a dubious idea because the internal organization of manual page directories varies in about a dozen respects among operating systems, so even if you get the answer, there is no portable way to use it for looking up anything inside. However, Matej Cepl made me aware that some software, for example the manual viewing functionality in the newest editors/neovim code, unwisely relies on this feature anyway. No objections were raised when this patch was shown on tech@. Modified Files: -------------- mandoc: main.c man.1 Revision Data ------------- Index: man.1 =================================================================== RCS file: /home/cvs/mandoc/mandoc/man.1,v retrieving revision 1.36 retrieving revision 1.37 diff -Lman.1 -Lman.1 -u -p -r1.36 -r1.37 --- man.1 +++ man.1 @@ -3,7 +3,7 @@ .\" Copyright (c) 1989, 1990, 1993 .\" The Regents of the University of California. All rights reserved. .\" Copyright (c) 2003, 2007, 2008, 2014 Jason McIntyre -.\" Copyright (c) 2010, 2011, 2014-2018 Ingo Schwarze +.\" Copyright (c) 2010, 2011, 2014-2020 Ingo Schwarze .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions @@ -199,6 +199,9 @@ Kernel internals. .It Fl w List the pathnames of all matching manual pages instead of displaying any of them. +If no +.Ar name +is given, list the directories that would be searched. .El .Pp The options Index: main.c =================================================================== RCS file: /home/cvs/mandoc/mandoc/main.c,v retrieving revision 1.342 retrieving revision 1.343 diff -Lmain.c -Lmain.c -u -p -r1.342 -r1.343 --- main.c +++ main.c @@ -448,8 +448,20 @@ main(int argc, char *argv[]) /* man(1): Resolve each name individually. */ if (search.argmode == ARG_NAME) { - if (argc < 1) - usage(ARG_NAME); + if (argc < 1) { + if (outmode != OUTMODE_FLN) + usage(ARG_NAME); + if (conf.manpath.sz == 0) { + warnx("The manpath is empty."); + mandoc_msg_setrc(MANDOCLEVEL_BADARG); + } else { + for (i = 0; i + 1 < conf.manpath.sz; i++) + printf("%s:", conf.manpath.paths[i]); + printf("%s\n", conf.manpath.paths[i]); + } + manconf_free(&conf); + return (int)mandoc_msg_getrc(); + } for (res = NULL, ressz = 0; argc > 0; argc--, argv++) { (void)mansearch(&search, &conf.manpath, 1, argv, &resn, &resnsz); -- To unsubscribe send an email to source+unsubscribe@mandoc.bsd.lv