{"thread":{"id":"3879","subject":"[RFC/PATCH] pager: do not fork a pager if environment variable PAGER is set to NONE","startedAt":"2006-04-15T13:16:36Z","lastAt":"2006-04-16T02:44:25Z","messageCount":5,"participants":["Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"18699","messageId":"Pine.LNX.4.63.0604151516150.6563@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"3879","inReplyTo":null,"subject":"[RFC/PATCH] pager: do not fork a pager if environment variable PAGER is set to NONE","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-04-15T13:16:36Z","receivedAt":"2006-04-15T13:16:36Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nThis helps debugging tremendously.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n pager.c |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\na91a9371e117555a03cfe7d24515787fb13005b6\ndiff --git a/pager.c b/pager.c\nindex 1364e15..1136adf 100644\n--- a/pager.c\n+++ b/pager.c\n@@ -5,9 +5,8 @@ #include \"cache.h\"\n  * something different on Windows, for example.\n  */\n \n-static void run_pager(void)\n+static void run_pager(const char *prog)\n {\n-\tconst char *prog = getenv(\"PAGER\");\n \tif (!prog)\n \t\tprog = \"less\";\n \tsetenv(\"LESS\", \"-S\", 0);\n@@ -16,10 +15,11 @@ static void run_pager(void)\n \n void setup_pager(void)\n {\n+\tconst char *prog = getenv(\"PAGER\");\n \tpid_t pid;\n \tint fd[2];\n \n-\tif (!isatty(1))\n+\tif (!isatty(1) || (prog != NULL && !strcmp(prog, \"NONE\")))\n \t\treturn;\n \tif (pipe(fd) < 0)\n \t\treturn;\n@@ -43,6 +43,6 @@ void setup_pager(void)\n \tclose(fd[0]);\n \tclose(fd[1]);\n \n-\trun_pager();\n+\trun_pager(prog);\n \texit(255);\n }\n-- \n1.3.0.rc4.g667c\n"},{"id":"18712","messageId":"7vwtdqef6u.fsf@assigned-by-dhcp.cox.net","threadId":"3879","inReplyTo":"Pine.LNX.4.63.0604151516150.6563@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [RFC/PATCH] pager: do not fork a pager if environment variable PAGER is set to NONE","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-04-15T20:50:33Z","receivedAt":"2006-04-15T20:50:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> This helps debugging tremendously.\n>\n> Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\nI like what this wants to do.  I am not so sure PAGER=NONE is a\ngood convention, however.\n"},{"id":"18720","messageId":"Pine.LNX.4.63.0604160357460.31461@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"3879","inReplyTo":"7vwtdqef6u.fsf@assigned-by-dhcp.cox.net","subject":"Re: [RFC/PATCH] pager: do not fork a pager if environment variable PAGER is set to NONE","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-04-16T02:01:30Z","receivedAt":"2006-04-16T02:01:30Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 15 Apr 2006, Junio C Hamano wrote:\n\n> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n> \n> > This helps debugging tremendously.\n> >\n> > Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n> \n> I like what this wants to do.  I am not so sure PAGER=NONE is a\n> good convention, however.\n\nI am sure it is not.\n\nOne solution would be to introduce yet another command line option \n\"--no-pager\", but I find that ugly.\n\nAnother solution would be to check if the environment variable NO_PAGER is \nset.\n\nWishes?\n\nCiao,\nDscho\n"},{"id":"18722","messageId":"7v4q0udzwg.fsf@assigned-by-dhcp.cox.net","threadId":"3879","inReplyTo":"Pine.LNX.4.63.0604160357460.31461@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [RFC/PATCH] pager: do not fork a pager if environment variable PAGER is set to NONE","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-04-16T02:20:47Z","receivedAt":"2006-04-16T02:20:47Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> Hi,\n>\n> On Sat, 15 Apr 2006, Junio C Hamano wrote:\n>\n>> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n>> \n>> > This helps debugging tremendously.\n>> >\n>> > Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n>> \n>> I like what this wants to do.  I am not so sure PAGER=NONE is a\n>> good convention, however.\n>\n> I am sure it is not.\n>\n> One solution would be to introduce yet another command line option \n> \"--no-pager\", but I find that ugly.\n>\n> Another solution would be to check if the environment variable NO_PAGER is \n> set.\n>\n> Wishes?\n\nHonestly, undecided.  Not that I think people would do\nPAGER=NONE to mean a program /usr/bin/NONE.\n\nRight now, the following does not say anything:\n\n\t$ PAGER= git log\n\nbut I do not think that is a reasonably behaviour, either.  So\ndetecting PAGER is set to an empty string (not \"nonexistence\" -\nthe current behaviour of defaulting to \"less\" in such a case is\nreasonable) is probably a better alternative.\n\nA somewhat related topic; I often set PAGER=cat when I do not\nwant the --[More]-- prompt and I thing many Emacs users do this.\nIt might also be good to detect it and omit piping in such a\ncase, but that is independent, so if you are going to do this as\nwell, please make it a separate patch.\n"},{"id":"18724","messageId":"Pine.LNX.4.63.0604160438370.32484@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"3879","inReplyTo":"7v4q0udzwg.fsf@assigned-by-dhcp.cox.net","subject":"Re: [RFC/PATCH] pager: do not fork a pager if environment variable PAGER is set to NONE","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2006-04-16T02:44:25Z","receivedAt":"2006-04-16T02:44:25Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Sat, 15 Apr 2006, Junio C Hamano wrote:\n\n> A somewhat related topic; I often set PAGER=cat when I do not\n> want the --[More]-- prompt and I thing many Emacs users do this.\n> It might also be good to detect it and omit piping in such a\n> case, but that is independent, so if you are going to do this as\n> well, please make it a separate patch.\n\nI was not quite sure if PAGER=cat could be taken as \"user does not want \nany pager to be fork()ed\", but you are probably right: PAGER=cat means \nthat stdout is forwarded to stdout, i.e. we are better off not fork()ing \nand calling \"cat\":\n\n---\n[PATCH] pager: do not fork a pager if PAGER=cat\n\nThis helps debugging tremendously.\n\nSigned-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>\n\n---\n\n pager.c |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\n4a617a436bba9288cec5d3918d02c5b0e652df98\ndiff --git a/pager.c b/pager.c\nindex 1364e15..86e93b3 100644\n--- a/pager.c\n+++ b/pager.c\n@@ -5,9 +5,8 @@ #include \"cache.h\"\n  * something different on Windows, for example.\n  */\n \n-static void run_pager(void)\n+static void run_pager(const char *prog)\n {\n-\tconst char *prog = getenv(\"PAGER\");\n \tif (!prog)\n \t\tprog = \"less\";\n \tsetenv(\"LESS\", \"-S\", 0);\n@@ -16,10 +15,11 @@ static void run_pager(void)\n \n void setup_pager(void)\n {\n+\tconst char *prog = getenv(\"PAGER\");\n \tpid_t pid;\n \tint fd[2];\n \n-\tif (!isatty(1))\n+\tif (!isatty(1) || (prog != NULL && !strcmp(prog, \"cat\")))\n \t\treturn;\n \tif (pipe(fd) < 0)\n \t\treturn;\n@@ -43,6 +43,6 @@ void setup_pager(void)\n \tclose(fd[0]);\n \tclose(fd[1]);\n \n-\trun_pager();\n+\trun_pager(prog);\n \texit(255);\n }\n-- \n1.3.0.rc4.gb6b20-dirty\n"}]}