tech-userlevel archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[PATCH] make man -p return zero exit code
man -p returns 1 error code, because the control flow of the program
keeps looking at the remaining arguments (empty list) and it doesn't
find a matching manual page.
Fish (shell) has gone through this flow process:
1. Append its own weirdo-shell manual pages to the MANPATH, but only if
you are using fish.
This is a logical choice, because the fish shell man pages are very
wrong for other shells, and they will be confusing otherwise.
So now it has an override of `man`.
2. NetBSD does not supply `man -p` output that is usable as MANPATH, so
add processing specific to NetBSD.
3. To tell NetBSD apart from others, expect `man -p` with no arguments
to return success
This is done because FreeBSD man also accepts a -p flag, but requires an
argument.
Unfortunately, this isn't possible, because `man -p` on NetBSD
returns non-zero status if no argument is passed.
-----
So, the following patch to quit processing the output if the -p flag is
passed.
This however changes the behaviour, if you wanted the man -p output AND
to see a man page, it will no longer work.
Objections?
Index: man.c
===================================================================
RCS file: /cvsroot/src/usr.bin/man/man.c,v
retrieving revision 1.67
diff -u -r1.67 man.c
--- man.c 15 Jun 2018 20:16:35 -0000 1.67
+++ man.c 3 Apr 2020 11:06:17 -0000
@@ -363,8 +363,10 @@
}
- if (m.getpath)
+ if (m.getpath) {
printmanpath(&m);
+ exit(cleanup());
+ }
/*
* now m.mymanpath is complete!
Home |
Main Index |
Thread Index |
Old Index