{"thread":{"id":"8392","subject":"[PATCH] Show html help with git-help --html","startedAt":"2007-06-02T01:53:41Z","lastAt":"2007-06-04T23:29:56Z","messageCount":6,"participants":["Nguyễn Thái Ngọc Duy","Junio C Hamano","Nguyen Thai Ngoc Duy"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"43783","messageId":"20070602015341.GA26520@localhost.myhome.westell.com","threadId":"8392","inReplyTo":null,"subject":"[PATCH] Show html help with git-help --html","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2007-06-02T01:53:41Z","receivedAt":"2007-06-02T01:53:41Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"This patch was inspired by ClearCase command 'ct man' which\nopens an html help file on Windows. I at first attempted to\nimplement it for MinGW port only but found it so useful that I\nwanted to have it even in Linux.\n\nA new option '--help' is added to git. When git-help is called\nwith --help, it will try to open html files located at\n$(sharedir)/html using xdg-open. HTML files are not installed\nby default so users have to install them manually or have their\ndistributors to do that.\n\nThere are two new config options introduced in this patch. The\nfirst is core.help. It has one of three values: html, auto or\nman. 'html' has the same effect as git-help --html. 'auto'\nwill in addition fall back to man pages if possible. 'man'\nis 'I hate html, give me my man pages'.  The second option is\ncore.htmlprogram, used to specify the program you want to\nopen html files instead of xdg-open.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n---\n Documentation/config.txt |   12 ++++++++++\n Documentation/git.txt    |    5 +++-\n Makefile                 |    5 +++-\n cache.h                  |    2 +\n config.c                 |   17 ++++++++++++++\n environment.c            |    2 +\n git.c                    |    2 +-\n help.c                   |   53 ++++++++++++++++++++++++++++++++++++++++++++-\n 8 files changed, 93 insertions(+), 5 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 3d8f03d..2ec8545 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -261,6 +261,18 @@ core.excludeFile::\n \t'.git/info/exclude', git looks into this file for patterns\n \tof files which are not meant to be tracked.\n \n+core.help::\n+\tIf 'html', it is equivalent to 'git-help' with option --html.\n+\tIf 'auto', it tries to open html files first. If that attempt fails\n+\t(the html program does not exist or the program return non-zero\n+\tvalue), then it will fall back to man pages. If 'man', always use\n+\tman pages as usual.\n+\n+core.htmlprogram::\n+\tSpecify the program used to open html help files when 'git-help'\n+\tis called with option --html or core.help is other than 'man'.\n+\tBy default, xdg-open will be used.\n+\n alias.*::\n \tCommand aliases for the gitlink:git[1] command wrapper - e.g.\n \tafter defining \"alias.last = cat-file commit HEAD\", the invocation\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex 98860af..589ebea 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -10,7 +10,7 @@ SYNOPSIS\n --------\n [verse]\n 'git' [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate]\n-    [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]\n+    [--bare] [--git-dir=GIT_DIR] [--help [--html]] COMMAND [ARGS]\n \n DESCRIPTION\n -----------\n@@ -87,6 +87,9 @@ OPTIONS\n \tcommands.  If a git command is named this option will bring up\n \tthe man-page for that command. If the option '--all' or '-a' is\n \tgiven then all available commands are printed.\n+\tIf option '--html' is given, try opening html files instead of\n+\tusing 'man'. The default program to open html files is xdg-open.\n+\tSee 'git-config' to know how to change html program.\n \n --exec-path::\n \tPath to wherever your core git programs are installed.\ndiff --git a/Makefile b/Makefile\nindex cac0a4a..43e0d15 100644\n--- a/Makefile\n+++ b/Makefile\n@@ -145,6 +145,7 @@ prefix = $(HOME)\n bindir = $(prefix)/bin\n gitexecdir = $(bindir)\n sharedir = $(prefix)/share/\n+htmldir = $(sharedir)/html/\n template_dir = $(sharedir)/git-core/templates/\n ifeq ($(prefix),/usr)\n sysconfdir = /etc\n@@ -693,6 +694,7 @@ ETC_GITCONFIG_SQ = $(subst ','\\'',$(ETC_GITCONFIG))\n DESTDIR_SQ = $(subst ','\\'',$(DESTDIR))\n bindir_SQ = $(subst ','\\'',$(bindir))\n gitexecdir_SQ = $(subst ','\\'',$(gitexecdir))\n+htmldir_SQ = $(subst ','\\'',$(htmldir))\n template_dir_SQ = $(subst ','\\'',$(template_dir))\n prefix_SQ = $(subst ','\\'',$(prefix))\n \n@@ -741,7 +743,8 @@ git$X: git.c common-cmds.h $(BUILTIN_OBJS) $(GITLIBS) GIT-CFLAGS\n \t\t$(ALL_CFLAGS) -o $@ $(filter %.c,$^) \\\n \t\t$(BUILTIN_OBJS) $(ALL_LDFLAGS) $(LIBS)\n \n-help.o: common-cmds.h\n+help.o: help.c common-cmds.h\n+\t$(QUIET_CC)$(CC) -o $*.o -c $(ALL_CFLAGS) -DHTML_DIR='\"$(htmldir_SQ)\"' $<\n \n git-merge-subtree$X: git-merge-recursive$X\n \t$(QUIET_BUILT_IN)rm -f $@ && ln git-merge-recursive$X $@\ndiff --git a/cache.h b/cache.h\nindex 0da7070..7a438ed 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -288,6 +288,8 @@ extern size_t packed_git_window_size;\n extern size_t packed_git_limit;\n extern size_t delta_base_cache_limit;\n extern int auto_crlf;\n+extern int show_html_help;\n+extern const char *html_help_program;\n \n #define GIT_REPO_VERSION 0\n extern int repository_format_version;\ndiff --git a/config.c b/config.c\nindex 0614c2b..d216ab7 100644\n--- a/config.c\n+++ b/config.c\n@@ -382,6 +382,23 @@ int git_default_config(const char *var, const char *value)\n \t\treturn 0;\n \t}\n \n+\tif (!strcmp(var, \"core.help\")) {\n+\t\tif (!strcmp(value, \"auto\"))\n+\t\t\tshow_html_help = 2;\n+\t\telse if (!strcmp(value, \"html\"))\n+\t\t\tshow_html_help = 1;\n+\t\telse if (!strcmp(value, \"man\"))\n+\t\t\tshow_html_help = 0;\n+\t\telse\n+\t\t\treturn 1;\n+\t\treturn 0;\n+\t}\n+\n+\tif (!strcmp(var, \"core.htmlprogram\")) {\n+\t\thtml_help_program = xstrdup(value);\n+\t\treturn 0;\n+\t}\n+\n \t/* Add other config variables here and to Documentation/config.txt. */\n \treturn 0;\n }\ndiff --git a/environment.c b/environment.c\nindex 9d3e5eb..e905972 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -32,6 +32,8 @@ size_t delta_base_cache_limit = 16 * 1024 * 1024;\n int pager_in_use;\n int pager_use_color = 1;\n int auto_crlf = 0;\t/* 1: both ways, -1: only when adding git objects */\n+int show_html_help = 0;\n+const char *html_help_program = NULL;\n \n static const char *git_dir;\n static char *git_object_dir, *git_index_file, *git_refs_dir, *git_graft_file;\ndiff --git a/git.c b/git.c\nindex 29b55a1..c3c0fe8 100644\n--- a/git.c\n+++ b/git.c\n@@ -4,7 +4,7 @@\n #include \"quote.h\"\n \n const char git_usage_string[] =\n-\t\"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--help] COMMAND [ARGS]\";\n+\t\"git [--version] [--exec-path[=GIT_EXEC_PATH]] [-p|--paginate] [--bare] [--git-dir=GIT_DIR] [--help [--html]] COMMAND [ARGS]\";\n \n static void prepend_to_path(const char *dir, int len)\n {\ndiff --git a/help.c b/help.c\nindex 6a9af4d..e3e705b 100644\n--- a/help.c\n+++ b/help.c\n@@ -9,6 +9,10 @@\n #include \"common-cmds.h\"\n #include <sys/ioctl.h>\n \n+#ifndef HTML_DIR\n+#define HTML_DIR \"/usr/share/html/\"\n+#endif\n+\n /* most GUI terminals set COLUMNS (although some don't export it) */\n static int term_columns(void)\n {\n@@ -183,6 +187,36 @@ static void show_man_page(const char *git_cmd)\n \texeclp(\"man\", \"man\", page, NULL);\n }\n \n+static void show_html_page(const char *git_cmd)\n+{\n+\tconst char *html_dir;\n+\tint i,len,ret;\n+\tchar *p;\n+\n+\thtml_dir = HTML_DIR;\n+\tif (!html_help_program)\n+\t\thtml_help_program = \"xdg-open\";\n+\n+\t/* html_help_program space html_dir git- git_cmd .html */\n+\tlen = strlen(html_help_program) + 1 + strlen(html_dir) + 4 + strlen(git_cmd) + 5;\n+\tp = xmalloc(len + 1);\n+\n+\tstrcpy(p, html_help_program);\n+\tstrcat(p,\" \");\n+\tstrcat(p,html_dir);\n+\tif (prefixcmp(git_cmd, \"git\"))\n+\t\tstrcat(p,\"git-\");\n+\tstrcat(p,git_cmd);\n+\tstrcat(p,\".html\");\n+\n+\tret = system(p);\n+\n+\t/* fallback to man pages */\n+\tif (show_html_help > 1 && (ret == -1 || ret > 0))\n+\t\tshow_man_page(git_cmd);\n+\texit(0);\n+}\n+\n void help_unknown_cmd(const char *cmd)\n {\n \tprintf(\"git: '%s' is not a git-command\\n\\n\", cmd);\n@@ -214,8 +248,23 @@ int cmd_help(int argc, const char **argv, const char *prefix)\n \t\texit(1);\n \t}\n \n-\telse\n-\t\tshow_man_page(help_cmd);\n+\telse {\n+\t\tgit_config(git_default_config);\n+\t\tif (!strcmp(help_cmd, \"--html\")) {\n+\t\t\thelp_cmd = argc > 2 ? argv[2] : NULL;\n+\t\t\tif (!help_cmd) {\n+\t\t\t\tprintf(\"usage: %s\\n\\n\", git_usage_string);\n+\t\t\t\tlist_common_cmds_help();\n+\t\t\t\texit(1);\n+\t\t\t}\n+\t\t\tshow_html_help = 1;\n+\t\t}\n+\n+\t\tif (show_html_help)\n+\t\t\tshow_html_page(help_cmd);\n+\t\telse\n+\t\t\tshow_man_page(help_cmd);\n+\t}\n \n \treturn 0;\n }\n-- \n1.5.2\n"},{"id":"43915","messageId":"7vr6osn19e.fsf@assigned-by-dhcp.cox.net","threadId":"8392","inReplyTo":"20070602015341.GA26520@localhost.myhome.westell.com","subject":"Re: [PATCH] Show html help with git-help --html","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-03T22:04:13Z","receivedAt":"2007-06-03T22:04:13Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:\n\n> This patch was inspired by ClearCase command 'ct man' which\n> opens an html help file on Windows. I at first attempted to\n> implement it for MinGW port only but found it so useful that I\n> wanted to have it even in Linux.\n>\n> A new option '--help' is added to git. When git-help is called\n> with --help, it will try to open html files located at\n> $(sharedir)/html using xdg-open. HTML files are not installed\n> by default so users have to install them manually or have their\n> distributors to do that.\n\nDo you mean a new option '--html'?\n"},{"id":"43955","messageId":"7vps4cjg1w.fsf@assigned-by-dhcp.cox.net","threadId":"8392","inReplyTo":"20070602015341.GA26520@localhost.myhome.westell.com","subject":"Re: [PATCH] Show html help with git-help --html","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-06-04T08:10:35Z","receivedAt":"2007-06-04T08:10:35Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"> diff --git a/Documentation/config.txt b/Documentation/config.txt\n> index 3d8f03d..2ec8545 100644\n> --- a/Documentation/config.txt\n> +++ b/Documentation/config.txt\n> @@ -261,6 +261,18 @@ core.excludeFile::\n> ...\n> +core.htmlprogram::\n> +\tSpecify the program used to open html help files when 'git-help'\n> +\tis called with option --html or core.help is other than 'man'.\n> +\tBy default, xdg-open will be used.\n\nIs the program's calling convention something that needs to be\ncustomizable for this to be useful?\n\n> diff --git a/Makefile b/Makefile\n> index cac0a4a..43e0d15 100644\n> --- a/Makefile\n> +++ b/Makefile\n> @@ -145,6 +145,7 @@ prefix = $(HOME)\n>  bindir = $(prefix)/bin\n>  gitexecdir = $(bindir)\n>  sharedir = $(prefix)/share/\n> +htmldir = $(sharedir)/html/\n>  template_dir = $(sharedir)/git-core/templates/\n>  ifeq ($(prefix),/usr)\n>  sysconfdir = /etc\n\nIs it customary to have HTMLized documentation material for\ndifferent packages all together in a single .../share/html/\ndirectory, like manpages are placed in share/man/man1/\ndirectory?  I somehow had an impression that a layout to have\nhtml directory per package (i.e. share/doc/$pkg/html/) was more\ncommon.  I dunno.\n\n> diff --git a/help.c b/help.c\n> index 6a9af4d..e3e705b 100644\n> --- a/help.c\n> +++ b/help.c\n> @@ -183,6 +187,36 @@ static void show_man_page(const char *git_cmd)\n>  \texeclp(\"man\", \"man\", page, NULL);\n>  }\n>  \n> +static void show_html_page(const char *git_cmd)\n> +{\n> +\tconst char *html_dir;\n> +\tint i,len,ret;\n> +\tchar *p;\n> +\n> +\thtml_dir = HTML_DIR;\n> +\tif (!html_help_program)\n> +\t\thtml_help_program = \"xdg-open\";\n> +\n> +\t/* html_help_program space html_dir git- git_cmd .html */\n> +\tlen = strlen(html_help_program) + 1 + strlen(html_dir) + 4 + strlen(git_cmd) + 5;\n> +\tp = xmalloc(len + 1);\n> +\n> +\tstrcpy(p, html_help_program);\n> +\tstrcat(p,\" \");\n> +\tstrcat(p,html_dir);\n> +\tif (prefixcmp(git_cmd, \"git\"))\n> +\t\tstrcat(p,\"git-\");\n> +\tstrcat(p,git_cmd);\n> +\tstrcat(p,\".html\");\n> +\n> +\tret = system(p);\n\nThis is sloppy in the presense of potentially unsafe characters...\n"},{"id":"43975","messageId":"fcaeb9bf0706040629k489d4818sa291725cbbeead79@mail.gmail.com","threadId":"8392","inReplyTo":"7vps4cjg1w.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Show html help with git-help --html","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2007-06-04T13:29:22Z","receivedAt":"2007-06-04T13:29:22Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On 6/4/07, Junio C Hamano <gitster@pobox.com> wrote:\n> > diff --git a/Documentation/config.txt b/Documentation/config.txt\n> > index 3d8f03d..2ec8545 100644\n> > --- a/Documentation/config.txt\n> > +++ b/Documentation/config.txt\n> > @@ -261,6 +261,18 @@ core.excludeFile::\n> > ...\n> > +core.htmlprogram::\n> > +     Specify the program used to open html help files when 'git-help'\n> > +     is called with option --html or core.help is other than 'man'.\n> > +     By default, xdg-open will be used.\n>\n> Is the program's calling convention something that needs to be\n> customizable for this to be useful?\n\nAt first I thought xdg-open would be flexible enough for most Linux\nsystems because it will choose the best browser you have. But I now\nrecall that Git does not only run on Linux.  Will make it a parameter\nin config.mak.in\n\n>\n> > diff --git a/Makefile b/Makefile\n> > index cac0a4a..43e0d15 100644\n> > --- a/Makefile\n> > +++ b/Makefile\n> > @@ -145,6 +145,7 @@ prefix = $(HOME)\n> >  bindir = $(prefix)/bin\n> >  gitexecdir = $(bindir)\n> >  sharedir = $(prefix)/share/\n> > +htmldir = $(sharedir)/html/\n> >  template_dir = $(sharedir)/git-core/templates/\n> >  ifeq ($(prefix),/usr)\n> >  sysconfdir = /etc\n>\n> Is it customary to have HTMLized documentation material for\n> different packages all together in a single .../share/html/\n> directory, like manpages are placed in share/man/man1/\n> directory?  I somehow had an impression that a layout to have\n> html directory per package (i.e. share/doc/$pkg/html/) was more\n> common.  I dunno.\n\nThe default value is not really useful. I would leave that for\ndistribution package mantainers to decide proper location because they\nhave to install html files separately anyway (at least in Gentoo).\nHowever it's not convenient for compiling-from-source users. Will redo\nthe patch and add rules to install html files also.\n\n>\n> > diff --git a/help.c b/help.c\n> > index 6a9af4d..e3e705b 100644\n> > --- a/help.c\n> > +++ b/help.c\n> > @@ -183,6 +187,36 @@ static void show_man_page(const char *git_cmd)\n> >       execlp(\"man\", \"man\", page, NULL);\n> >  }\n> >\n> > +static void show_html_page(const char *git_cmd)\n> > +{\n> > +     const char *html_dir;\n> > +     int i,len,ret;\n> > +     char *p;\n> > +\n> > +     html_dir = HTML_DIR;\n> > +     if (!html_help_program)\n> > +             html_help_program = \"xdg-open\";\n> > +\n> > +     /* html_help_program space html_dir git- git_cmd .html */\n> > +     len = strlen(html_help_program) + 1 + strlen(html_dir) + 4 + strlen(git_cmd) + 5;\n> > +     p = xmalloc(len + 1);\n> > +\n> > +     strcpy(p, html_help_program);\n> > +     strcat(p,\" \");\n> > +     strcat(p,html_dir);\n> > +     if (prefixcmp(git_cmd, \"git\"))\n> > +             strcat(p,\"git-\");\n> > +     strcat(p,git_cmd);\n> > +     strcat(p,\".html\");\n> > +\n> > +     ret = system(p);\n>\n> This is sloppy in the presense of potentially unsafe characters...\n\nI personally think users will not shoot themselves with \"git help\n--html ';rm -rf'\" but again scripts can. Thank you for pointing out.\nWill add check for file existence before calling system().\n-- \nDuy\n"},{"id":"44001","messageId":"7vvee3ih8s.fsf@assigned-by-dhcp.cox.net","threadId":"8392","inReplyTo":"fcaeb9bf0706040629k489d4818sa291725cbbeead79@mail.gmail.com","subject":"Re: [PATCH] Show html help with git-help --html","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-06-04T20:42:27Z","receivedAt":"2007-06-04T20:42:27Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Nguyen Thai Ngoc Duy\" <pclouds@gmail.com> writes:\n\n> On 6/4/07, Junio C Hamano <gitster@pobox.com> wrote:\n>> > diff --git a/Documentation/config.txt b/Documentation/config.txt\n>> > index 3d8f03d..2ec8545 100644\n>> > --- a/Documentation/config.txt\n>> > +++ b/Documentation/config.txt\n>> > @@ -261,6 +261,18 @@ core.excludeFile::\n>> > ...\n>> > +core.htmlprogram::\n>> > +     Specify the program used to open html help files when 'git-help'\n>> > +     is called with option --html or core.help is other than 'man'.\n>> > +     By default, xdg-open will be used.\n>>\n>> Is the program's calling convention something that needs to be\n>> customizable for this to be useful?\n>\n> At first I thought xdg-open would be flexible enough for most Linux\n> systems because it will choose the best browser you have. But I now\n> recall that Git does not only run on Linux.  Will make it a parameter\n> in config.mak.in\n\nActually that was not what I meant.  I thought we might need to\nsupport something like:\n\n\tcore.htmlprogram = grand-unified-help %b\n\nfor a program that knows where in the system the distribution\nkeeps help HTML files, and add prefix (/usr/share/html-help/,\nperhaps) and suffix (obviously, .html) to the basename of the\ncommand (e.g. \"grand-unified-help git-rebase\" ends up running\n\"lynx file:///usr/share/html-help/git-rebase.html\"), or perhaps\n\n\tcore.htmlprogram = firefox /usr/share/html-help/%f\n\nand we substitute '%f' with \"git-rebase.html\".\n\n>> ...\n>> > +     if (prefixcmp(git_cmd, \"git\"))\n>> > +             strcat(p,\"git-\");\n>> > +     strcat(p,git_cmd);\n>> > +     strcat(p,\".html\");\n>> > +\n>> > +     ret = system(p);\n>>\n>> This is sloppy in the presense of potentially unsafe characters...\n>\n> I personally think users will not shoot themselves with \"git help\n> --html ';rm -rf'\" but again scripts can. Thank you for pointing out.\n> Will add check for file existence before calling system().\n\nFile existence?  I am not sure what you mean by that, sorry.\n"},{"id":"44014","messageId":"fcaeb9bf0706041629tfd3c172md8790387493df43c@mail.gmail.com","threadId":"8392","inReplyTo":"7vvee3ih8s.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Show html help with git-help --html","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2007-06-04T23:29:56Z","receivedAt":"2007-06-04T23:29:56Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On 6/4/07, Junio C Hamano <junkio@cox.net> wrote:\n> \"Nguyen Thai Ngoc Duy\" <pclouds@gmail.com> writes:\n>\n> > On 6/4/07, Junio C Hamano <gitster@pobox.com> wrote:\n> >> > diff --git a/Documentation/config.txt b/Documentation/config.txt\n> >> > index 3d8f03d..2ec8545 100644\n> >> > --- a/Documentation/config.txt\n> >> > +++ b/Documentation/config.txt\n> >> > @@ -261,6 +261,18 @@ core.excludeFile::\n> >> > ...\n> >> > +core.htmlprogram::\n> >> > +     Specify the program used to open html help files when 'git-help'\n> >> > +     is called with option --html or core.help is other than 'man'.\n> >> > +     By default, xdg-open will be used.\n> >>\n> >> Is the program's calling convention something that needs to be\n> >> customizable for this to be useful?\n> >\n> > At first I thought xdg-open would be flexible enough for most Linux\n> > systems because it will choose the best browser you have. But I now\n> > recall that Git does not only run on Linux.  Will make it a parameter\n> > in config.mak.in\n>\n> Actually that was not what I meant.  I thought we might need to\n> support something like:\n>\n>         core.htmlprogram = grand-unified-help %b\n>\n> for a program that knows where in the system the distribution\n> keeps help HTML files, and add prefix (/usr/share/html-help/,\n> perhaps) and suffix (obviously, .html) to the basename of the\n> command (e.g. \"grand-unified-help git-rebase\" ends up running\n> \"lynx file:///usr/share/html-help/git-rebase.html\"), or perhaps\n>\n>         core.htmlprogram = firefox /usr/share/html-help/%f\n>\n> and we substitute '%f' with \"git-rebase.html\".\n\nOk. Now I get it.\n\n>\n> >> ...\n> >> > +     if (prefixcmp(git_cmd, \"git\"))\n> >> > +             strcat(p,\"git-\");\n> >> > +     strcat(p,git_cmd);\n> >> > +     strcat(p,\".html\");\n> >> > +\n> >> > +     ret = system(p);\n> >>\n> >> This is sloppy in the presense of potentially unsafe characters...\n> >\n> > I personally think users will not shoot themselves with \"git help\n> > --html ';rm -rf'\" but again scripts can. Thank you for pointing out.\n> > Will add check for file existence before calling system().\n>\n> File existence?  I am not sure what you mean by that, sorry.\n\nSomething like this on top of the last patch.\n\ndiff --git a/help.c b/help.c\nindex e3e705b..6f5c340 100644\n--- a/help.c\n+++ b/help.c\n@@ -191,7 +191,8 @@ static void show_html_page(const char *git_cmd)\n {\n        const char *html_dir;\n        int i,len,ret;\n-       char *p;\n+       char *p,*pathname;\n+       struct stat html_stat;\n\n        html_dir = HTML_DIR;\n        if (!html_help_program)\n@@ -203,13 +204,19 @@ static void show_html_page(const char *git_cmd)\n\n        strcpy(p, html_help_program);\n        strcat(p,\" \");\n+       pathname = p + strlen(p);\n        strcat(p,html_dir);\n        if (prefixcmp(git_cmd, \"git\"))\n                strcat(p,\"git-\");\n        strcat(p,git_cmd);\n        strcat(p,\".html\");\n\n-       ret = system(p);\n+       if (!stat(pathname, &html_stat))\n+               ret = system(p);\n+       else {\n+               error(\"%s not found\",pathname);\n+               ret = -1;\n+       }\n\n        /* fallback to man pages */\n        if (show_html_help > 1 && (ret == -1 || ret > 0))\n-- \nDuy\n"}]}