Re: [PATCH 3/3] git --help COMMAND brings up the git-COMMAND man-page.
- From
Junio C Hamano <junkio@cox.net>
- Date
- Nov 15, 2005, 23:49 UTC
- 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 <ae@op5.se>
Thanks, stupid is fine.
Show 19 quoted lines
> +/* 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.