From: Junio C Hamano Date: Tue, 15 Nov 2005 23:49:18 GMT Subject: Re: [PATCH 3/3] git --help COMMAND brings up the git-COMMAND man-page. Message-ID: <7vsltxeakh.fsf@assigned-by-dhcp.cox.net> In-Reply-To: <20051115233125.2C0355BF73@nox.op5.se> exon@op5.se (Andreas Ericsson) writes: > It's by design a bit stupid (matching ^git rather than ^git-), so as > to work with 'gitk' and 'git' as well. > > Signed-off-by: Andreas Ericsson Thanks, stupid is fine. > +/* has anyone seen 'man' installed anywhere else than in /usr/bin? */ > +#define PATH_TO_MAN "/usr/bin/man" > +static void show_man_page(char *git_cmd) > +{ > + char *page; > + > + if (!strncmp(git_cmd, "git", 3)) > + page = git_cmd; > + else { > + int page_len = strlen(git_cmd) + 4; > + > + page = malloc(page_len + 1); > + strcpy(page, "git-"); > + strcpy(page + 4, git_cmd); > + page[page_len] = 0; > + } > + > + execlp(PATH_TO_MAN, "man", page, NULL); > +} If you do PATH_TO_MAN absolute, execl would suffice, but just saying "man" and have execlp look for it would be easier to manage.