Commit graph

90 commits

Author SHA1 Message Date
Wolfram Schneider 965fff9826 man(1): ignore absolute path for .so include
We want only a relative include, as ".so man1/foobar.1"

MFC after:	1 week
2024-06-03 16:00:42 +00:00
Wolfram Schneider 73eb53813f man(1) needs to check for .so files not only in the first line
PR: 279182

Some manual pages have a copyright notice or commit id before including
other files with the .so macro. We need to skip comments and empty lines
at the beginning of the manpage while checking for the first .so macro.

MFC after:	1 week
2024-05-26 05:48:40 +00:00
Wolfram Schneider 37be4197f7 man: the exists function needs to validate the first parameter
This fixes an issue with the ".so " macro for FreeBSD
ports manual pages.

PR: 275978
Reported by:	Jamie Landeg-Jones <jamie@catflap.org>
MFC after:	1 week

Differential Revision:	https://reviews.freebsd.org/D45231 (discussion)
2024-05-20 16:02:21 +00:00
Wolfram Schneider 14a5c1068d man: do not ignore the exit status of roff tools
PR:		223516
Approved by:	emaste, bapt
Differential Revision:	https://reviews.freebsd.org/D44798
2024-04-20 08:30:33 +00:00
Mohamed Akram e85a6f8dff man: fix redirect for locales and file arguments
Use the locale-specific path for localized pages and the appropriate parent
directory for file arguments when handling redirects.

Signed-off-by: Mohamed Akram <mohd.akram@outlook.com>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1019
2024-02-02 18:34:59 -07:00
Wolfram Schneider b8a484ec34 man: support special characters in filenames
man.sh needs to handle double quotes and sub shell character
as '`' '$' etc.

PR:		275967
Reviewed by:	bapt

MFC after:	1 week
Differential Revision: https://reviews.freebsd.org/D43453
2024-01-25 07:14:06 +00:00
Mohamed Akram ec13a838e6 man: avoid unportable use of utilities
echo -e is not portable. It can be replaced by printf %b (it works
only with the /bin/sh built-in echo, not /bin/echo anyway).
head -# is not portable, but head -n # is.

Replace these two things in three places total.

Signed-off-by: Mohamed Akram <mohd.akram@outlook.com>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/1062
2024-01-15 11:30:37 -07:00
Wolfram Schneider e3c7b76fa8 man(1): support spaces in filenames
The globbing function in exists() needs to handle white spaces.

PR:          275978
Reviewed by: kevans, bapt, emaste
MFC after:   1 week
2024-01-13 16:16:55 +00:00
Wolfram Schneider 1e82d882ed fix using man(1) with multiple pages
PR: 275978
Reported by: Mohamed Akram
Fixes: 789480702e
MFC after: 1 week
2024-01-08 16:05:50 +00:00
Wolfram Schneider 789480702e support spaces in filenames
PR:		275978
MFC after:	1 week
2023-12-28 10:50:29 +00:00
Wolfram Schneider c4368d03e5 improve handling of shell metacharacters in filenames
PR:		275967
MFC after:	1 week
2023-12-27 17:36:51 +00:00
Wolfram Schneider cd89fe3923 switch groff parameter -man to -mandoc for new groff release 1.23.0
PR: 273565
2023-09-07 14:59:12 +00:00
Wolfram Schneider 035f7c9a36 switch groff parameter -man to -mandoc
groff 1.23.0 changed the semantics of the -man parameter, and many
manual pages are not rendered. The -mandoc parameter brings back
the old behavior, as in groff 1.22.4 and earlier.

PR: 273565, 273245

Reviewed by:	emaste, bapt
MFC after: 1 week for all supported branches (stable/12, 13, 14)
Differential Revision:	https://reviews.freebsd.org/D41737
2023-09-07 06:28:24 +00:00
Warner Losh fa9896e082 Remove $FreeBSD$: two-line nroff pattern
Remove /^\.\\"\n\.\\"\s*\$FreeBSD\$$\n/
2023-08-16 11:55:10 -06:00
Warner Losh d0b2dbfa0e Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:55:03 -06:00
Ed Maste 8a5c836b51 man: fix man -K search
Quote re arg to grep in case it has spaces, and quote [:blank:] tr arg
to avoid the shell interpreting [].

PR:		272729
Reviewed by:	Mina Galić <freebsd@igalic.co>
Sponsored by:	The FreeBSD Foundation
Differential Revision: https://reviews.freebsd.org/D41282
2023-08-02 16:46:57 -04:00
Mohamed Akram b35ea9bac9 man(1): use gzcat for .gz files
POSIX zcat appends the .Z suffix to file arguments causing the command to fail
with .gz files.

Signed-off-by: Mohamed Akram <mohd.akram@outlook.com>

Reviewed by:	markj
MFC after:	2 weeks
Pull Request:	https://github.com/freebsd/freebsd-src/pull/789
2023-07-04 15:42:55 -04:00
Mohamed Akram 8edb6fb572 man(1): Support custom sections
PR: 271830
Signed-off-by: Mohamed Akram <mohd.akram@outlook.com>
Reviewed by: imp
Pull Request: https://github.com/freebsd/freebsd-src/pull/764
2023-06-27 07:51:27 -06:00
Warner Losh 4d846d260e spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD
The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch
up to that fact and revert to their recommended match of BSD-2-Clause.

Discussed with:		pfg
MFC After:		3 days
Sponsored by:		Netflix
2023-05-12 10:44:03 -06:00
Cameron Katri c8abb673a5 man(1): Support zstd compressed manpages using zstdcat
Reviewed by:	emaste, markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D32296
2023-01-30 13:12:36 -05:00
Wolfram Schneider 433c5a8ae4 do not expect mandoc(1) to terminate in finite time
PR:		266868
2022-12-27 17:04:04 +00:00
Jens Schweikhardt 20f68c5f2d Indicate that xrefs to *roff,tbl,eqn et al are found in ports/textproc/groff. 2022-08-15 22:15:18 +02:00
Fernando Apesteguía 1594084f3f man(1): Add full search (-K) flag
This flag allows a full text search on man pages. Although this is a last resort
option, it can be useful to pin point a certain man page.

It can be used with -S to narrow the search.

Unlike the Linux version, the search takes place in the rendered text so it
avoids false-positives when the text is found in comments in the source files.

It relies on `grep(1)` and `mandoc(1)` to do its job.

Add flag documentation and EXAMPLES to the manual page (bump .Dd).

Usage example:

man -w -K '\<arm\>' -S 1:8

Reviewed By: ceri, emaste, pauamma_gundo.com
Approved by: manpages (bcr@), debdrup@
Differential Revision: https://reviews.freebsd.org/D30984
2022-01-26 12:24:20 +01:00
Kyle Evans f555b39e6b man: reset OPTIND before parsing args
From jilles: POSIX requires that a script set `OPTIND=1` before using
different sets of parameters with `getopts`, or the results will be
unspecified.

The specific problem observed here is that we would execute `man -f` or
`man -k` without cleaning up state from man_parse_args()' `getopts`
loop.  FreeBSD's /bin/sh seems to reset OPTIND to 1 after we hit the
second getopts loop, rendering the following shift harmless; other
/bin/sh implementations will leave it at what we came into the loop at
(e.g., bash as /bin/sh), shifting off any keywords that we had.

Input from:	jilles
Reviewed by:	allanjude, bapt, imp
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D32063
2021-09-23 14:13:34 -05:00
Fernando Apesteguía 9e23004023 man(1): Bump .Dd
From commit df965a6829
2021-01-09 18:22:08 +01:00
Fernando Apesteguía df965a6829 man(1): Add EXAMPLES section
Add some examples showing the use of the flags: a, k, P, w

Reviewed by: gbe@, yuripv@
Approved by: manpages (gbe@)
Differential Revision: https://reviews.freebsd.org/D27545
2021-01-09 17:57:47 +01:00
Mateusz Piotrowski e4c79332a0 Update the list of searched manual sections after r367013 2020-10-28 16:54:37 +00:00
Ryan Moeller 73577bf01d flua: Add a libjail module
libjail is pretty small, so it makes for a good proof of concept demonstrating
how a system library can be wrapped to create a loadable Lua module for flua.

* Introduce 3lua section for man pages
* Add libjail module

Reviewed by:	kevans, manpages
Relnotes:	yes
Differential Revision:	https://reviews.freebsd.org/D26080
2020-10-24 17:08:59 +00:00
Yuri Pankov 9508f8c05c Teach man(1) about C.UTF-8.
While here, use LANG as the proper source to select man pages language/encoding,
falling back to LC_CTYPE.

Reviewed by:	bapt
Approved by:	kib (mentor, implicit)
Differential Revision:	https://reviews.freebsd.org/D17835
2018-11-04 16:58:55 +00:00
Alan Somers 47cc9ee1b1 Switch the default pager for most commands to less
Finally, a pager for the nineties.

MFC after:	Never
Relnotes:	Yes
Differential Revision:	https://reviews.freebsd.org/D13465
Poll:		https://reviews.freebsd.org/V7
2018-08-08 19:24:20 +00:00
Edward Tomasz Napierala dcea542b0a Clean up .Xrs in man(1).
MFC after:	2 weeks
2018-04-25 15:39:36 +00:00
Eitan Adler 03cd714fc5 man(1): document exit code
man(1) uses standard exit codes, document that.

PR:		223517
Reported by:	wosch
MFC after:	1 week
2017-12-31 00:35:11 +00:00
Baptiste Daroussin 625490e842 Only skip looking for manpages if both man directory and cat directory
are not existing.

This allows man(1) to read catpages when no man directories are available at all

PR:		223559
Reported by:	wosch
MFC after:	3 days
2017-12-04 12:51:05 +00:00
Baptiste Daroussin d9405a926c In case man(1) found a catpage to display skip looking ".so" which is manpage
only.

In case we are trying to read a catpage, the manpage variable is not defined.
It results in the "cattool" having no arguments.

In case the catpage is compressed, the cattool used is "zcat" which dies if the
standard input is a terminal, meaning the function calling it is exiting as if
there were no ".so"
In case the catpage is uncompressed, the cattool used is "zcat -f" which waits
reading standard input, making the man(1) command hang.

PR:		223560
Reported by:	wosch
MFC after:	3 days
2017-12-04 12:33:46 +00:00
Pedro F. Giffuni 1de7b4b805 various: general adoption of SPDX licensing ID tags.
Mainly focus on files that use BSD 2-Clause license, however the tool I
was using misidentified many licenses so this was mostly a manual - error
prone - task.

The Software Package Data Exchange (SPDX) group provides a specification
to make it easier for automated tools to detect and summarize well known
opensource licenses. We are gradually adopting the specification, noting
that the tags are considered only advisory and do not, in any way,
superceed or replace the license texts.

No functional change intended.
2017-11-27 15:37:16 +00:00
Baptiste Daroussin 451c2bec47 man(1): silent the output of mandoc when testing
This reduce the spam a user may face when mandoc tries to
figure out if it can renders a manpage or fallback on groff(1)

Reported by:	bdrewery
MFC after:	3 days
2017-09-29 07:44:48 +00:00
Tijl Coosemans 971c1c4219 - Remove separate handling of /bin and /usr/bin in manpath. They are no
longer a special case.
- Prefer PREFIX/share/man over PREFIX/man.
- Add /usr/local/share/man to man_default_path.
- Update manpath man page.

Reviewed by:	bapt
2017-03-12 10:56:19 +00:00
Baptiste Daroussin 97ab006d51 Remove the WITHOUT_MANDOCDB option
mandoc database is activated since FreeBSD 11.0, let's remove the previous
database format for FreeBSD 12.0
2017-03-11 06:51:21 +00:00
Baptiste Daroussin 6970ca8f1e Remove the warning when MANPATH is set in the environment
The MANPATH environment variable behaviour is documented properly in the manpage
and it now has extended to new feature that allows to make MANPATH env variable
extending the default search path rather than overwriting it making the warning
painful

Reported by:	kargl
MFC after:	1 week
2017-03-11 06:31:16 +00:00
Baptiste Daroussin b2394e73fc Extend functionality MANPATH in man(1) to followup with apropos(1) from
mandoc.

If MANPATH begins with a colon, it is appended to the default list; if it ends
with a colon, it is prepended to the default list; or if it contains two
adjacent colons, the standard search path is inserted between the colons.  If
none of these conditions are met, it overrides the standard search path.

Import the MANPATH description from mandoc into the man(1) man page

Reported by:	kargl
MFC after:	1 week
2017-03-11 06:24:49 +00:00
Baptiste Daroussin 61d5f2d162 Add share/man if it exists to the MANPATH
localbase is not consistent with base for manpages:
/usr/local/man vs /usr/share/man adding share/man allows to fix that
inconsistency and would permit to remove tons of patches/modifications in the
ports tree
2017-03-11 05:56:50 +00:00
Enji Cooper dad206bd67 Update MACHINE/MACHINE_ARCH examples to use arm64/aarch64 instead of i386/pc98
pc98 support was removed in r312910
2017-01-29 00:24:34 +00:00
Baptiste Daroussin 449a792dd5 Restore man -t for manpages rendered by mandoc
Reported by:	swills
2015-09-19 16:00:50 +00:00
Baptiste Daroussin 24ef74209a inode should be different to actually mean mandocdb is in used
Sponsored by:	gandi.net
2015-07-24 09:20:02 +00:00
Baptiste Daroussin 772246ef18 Fix man -k with mandocdb
If apropos(1) and whatis(1) are not hardlinks to man(1) that means the system is
using mandocdb, then man -k should spawn apropos(1) and/or whatis(1) directly

Reported by:	kevlo
Tested by:	kevlo
Sponsored by:	gandi.net
2015-07-24 09:10:03 +00:00
Simon J. Gerraty ccfb965433 Add META_MODE support.
Off by default, build behaves normally.
WITH_META_MODE we get auto objdir creation, the ability to
start build from anywhere in the tree.

Still need to add real targets under targets/ to build packages.

Differential Revision:       D2796
Reviewed by: brooks imp
2015-06-13 19:20:56 +00:00
Simon J. Gerraty 44d314f704 dirdeps.mk now sets DEP_RELDIR 2015-06-08 23:35:17 +00:00
Baptiste Daroussin 8faa40d1a0 Switch to mandoc's version of makewhatis(8), whatis(1), apropos(1) utilities.
This change among other things improve search capabilities over the manpages
allowing fine grain query.

A new build option WITHOUT_MANDOCDB has been added to keep the ancient version
of the database and the tools. The plan is to entirely remove this option before
11.0-RELEASE.

Differential Revision:	https://reviews.freebsd.org/D2603
2015-05-30 17:41:37 +00:00
Simon J. Gerraty 98e0ffaefb Merge sync of head 2015-05-27 01:19:58 +00:00
Baptiste Daroussin d433cf9a8a Allow MANWIDTH to work with mandoc(1)
Reported by:	bdrewery
2015-05-15 15:56:28 +00:00