Fixing up man pages

Roman Neuhauser neuhauser at sigpipe.cz
Sun Jul 31 14:11:07 GMT 2005


# pauls at utdallas.edu / 2005-07-30 15:03:35 -0500:
> --On July 30, 2005 11:26:05 AM +0200 Roman Neuhauser <neuhauser at sigpipe.cz> 
> wrote:
> 
> ># pauls at utdallas.edu / 2005-07-29 19:10:59 -0500:
> >>I'm working on updating the x11-toolkits/iwidgets port, and I've run
> >>into a  problem.  The man pages install fine, but they aren't formatted
> >>correctly.
> >
> >    What does "formatted correctly" mean? Can you paste the output, and
> >    what you want it to look like instead?
> >
> >>In the Makefile for the source, there is a section that deals with the
> >>man  pages like this:
> >>
> >>@cd $(TOP_DIR)/doc; for i in *.n; \
> >>           do \
> >>           rm -f $(MAN_INSTALL_DIR)/`basename $$i`; \
> >>           rm -f $(MAN_INSTALL_DIR)/`basename iwidgets_$$i`; \
> >>           sed -e '/man\.macros/r man.macros' -e '/man\.macros/d' \
> >>               $$i > $(MAN_INSTALL_DIR)/`basename iwidgets_$$i`; \
> >>           chmod 444 $(MAN_INSTALL_DIR)/`basename iwidgets_$$i`; \
> >>           done;
> >>
> >>How can I incorporate this into the port Makefile so that the man pages
> >>will be properly formatted?
> >
> >    The only "formatting" this does is replace the first occurrence
> >    of "man.macros" on any line with the contents of
> >    $(TOP_DIR)/doc/man.macros. Is that's what you mean?
>
> I posted a question about the sed script in questions, and once I 
> understood the guy's answer (which took a while), I got it working.
> 
> Here's the working version:
> 
> @${SED} -e '/man\.macros/r ${WRKSRC}/doc/man.macros' \
>               -e '/man\.macros/d' ${WRKSRC}/doc/${f} > ${WRKDIR}/${f}
> 
> What this does is parse man.macros for the string man\.macros and, if 
> found, use it as input to the second part that removes the string 
> man\.macros from the input stream and then feeds it to the file ${f}, which 
> is the manpage in the source.  Once the macro is in the manpage, man can 
> display it properly.

    That's incorrect. This is what it looks like again:

    ${SED} -e '/man\.macros/r ${WRKSRC}/doc/man.macros' 
    -e '/man\.macros/d' ${WRKSRC}/doc/${f} > ${WRKDIR}/${f}

    You need to remember that:

    1. After any and all processing, sed prints each line of input
       (stdin or an argument) to stdout unless told otherwise.
       ("sed file" is just like "cat file" except dumb)

    2. "sed -e 'cmd1' -e 'cmd2'" is the same as "sed -e "cmd1;cmd2".

    3. The "r" command causes sed to "Copy the contents of file to
       the standard output immediately before the next attempt to read a
       line of input." (man page)

    4. The "d" command causes sed to delete the currently processed line
       and read the next one (but before that, sed passes through the
       contents of man.macros as scheduled in step 3).

    The above detailed behavior results in every line of input replaced
    with the contents of ${WRKSRC}/doc/man.macros. This is done for every
    file in ${TOPD_DIR}/doc whose name ends in ".n", and the result is
    saved in $(MAN_INSTALL_DIR)/`basename iwidgets_$$i` I hope it's a
    comprehensible explanation.

    IOW, for each X in $(TOP_DIR)/doc/*.n, $(MAN_INSTALL_DIR)/iwidgets_X`
    is created with contents copied from the source except lines
    containing "man.macros" replaced by the contents of the file called
    "man.macros".

> One final question.  Do I submit this as patches to the existing port?  Or 
> just submit it as if it's a new port?  (It's completely different from the 
> existing port in the way it handles the install.)

    Patches, IMO.

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991


More information about the freebsd-ports mailing list