{"thread":{"id":"18529","subject":"[BUG] Infinite loop in git send-email if ran non-interactively.","startedAt":"2009-03-25T09:36:55Z","lastAt":"2009-03-25T16:23:56Z","messageCount":5,"participants":["Matthieu Moy","Jay Soffian"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"109329","messageId":"vpqiqlyj64o.fsf@bauges.imag.fr","threadId":"18529","inReplyTo":null,"subject":"[BUG] Infinite loop in git send-email if ran non-interactively.","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2009-03-25T09:36:55Z","receivedAt":"2009-03-25T09:36:55Z","isPatch":false,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Hi,\n\nI've been hit by c1f2aa45b (send-email: add --confirm option and\nconfiguration setting) running git send-email from a cron job.\n\nThe problem is that the cron job is ran non-interactively, and\ntherefore the confirmation question in git-send-email.perl goes\ninfinite loop:\n\n\t\twhile (1) {\n\t\t\tchomp ($_ = $term->readline(\n\t\t\t\t\"Send this email? ([y]es|[n]o|[q]uit|[a]ll): \"\n\t\t\t));\n                        print \"answer=$_.\\n\";\n\t\t\tlast if /^(?:yes|y|no|n|quit|q|all|a)/i;\n\t\t\tprint \"\\n\";\n\t\t}\n\nInfinite loop is bad, but it gets even worse since this prints error\nmessages to stdout, and therefore to a log file in the case of my\nscript. In short, I woke up this morning with a file filling my disk\nwith\n\nprint() on closed filehandle FOUT at /usr/share/perl/5.8/Term/ReadLine.pm line 193.\nreadline() on closed filehandle FIN at /usr/share/perl/5.8/Term/ReadLine.pm line 395.\nprint() on closed filehandle FOUT at /usr/share/perl/5.8/Term/ReadLine.pm line 203.\nUse of uninitialized value in scalar chomp at /home/moy/local/usr/libexec/git-core//git-send-email line 856.\nUse of uninitialized value in pattern match (m//) at /home/moy/local/usr/libexec/git-core//git-send-email line 859.\nprint() on closed filehandle FOUT at /usr/share/perl/5.8/Term/ReadLine.pm line 193.\nreadline() on closed filehandle FIN at /usr/share/perl/5.8/Term/ReadLine.pm line 395.\nprint() on closed filehandle FOUT at /usr/share/perl/5.8/Term/ReadLine.pm line 203.\nUse of uninitialized value in scalar chomp at /home/moy/local/usr/libexec/git-core//git-send-email line 856.\nUse of uninitialized value in pattern match (m//) at /home/moy/local/usr/libexec/git-core//git-send-email line 859.\n...\n\nI think, non-interactive runs of send-email should assume \"yes\"\ninstead of prompting. In any case, it should not do infinite loop (I\nguess I don't have to argue for this ;-) )\n\nCan someone more fluent in perl than me add a\n\nif(session-is-interactive) {\n...\n}\n\naround this confirmation prompt?\n\n(side-note : there is indeed some code to handle the cases where the\nterminal doesn't work with readline, added by Junio in 280242d1, but\nthe FakeTerm part doesn't seem to be executed in my case:\n\nmy $term = eval {\n\t$ENV{\"GIT_SEND_EMAIL_NOTTY\"}\n\t\t? new Term::ReadLine 'git-send-email', \\*STDIN, \\*STDOUT\n\t\t: new Term::ReadLine 'git-send-email';\n};\nif ($@) {\n\t$term = new FakeTerm \"$@: going non-interactive\";\n}\n)\n\n(in the meantime, I'll add --confirm never to my script)\n\nThanks,\n\n--\nMatthieu\n"},{"id":"109364","messageId":"76718490903250903t530983abi8a641e6b7aee6c0@mail.gmail.com","threadId":"18529","inReplyTo":"vpqiqlyj64o.fsf@bauges.imag.fr","subject":"Re: [BUG] Infinite loop in git send-email if ran non-interactively.","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-03-25T16:03:17Z","receivedAt":"2009-03-25T16:03:17Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Wed, Mar 25, 2009 at 5:36 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:\n> I think, non-interactive runs of send-email should assume \"yes\"\n\nHmm, probably.\n\n> instead of prompting. In any case, it should not do infinite loop (I\n> guess I don't have to argue for this ;-) )\n\nRight, I'll followup with a fix.\n\n> Can someone more fluent in perl than me add a\n>\n> if(session-is-interactive) {\n> ...\n> }\n>\n> around this confirmation prompt?\n>\n> (side-note : there is indeed some code to handle the cases where the\n> terminal doesn't work with readline, added by Junio in 280242d1, but\n> the FakeTerm part doesn't seem to be executed in my case:\n>\n> my $term = eval {\n>        $ENV{\"GIT_SEND_EMAIL_NOTTY\"}\n>                ? new Term::ReadLine 'git-send-email', \\*STDIN, \\*STDOUT\n>                : new Term::ReadLine 'git-send-email';\n> };\n> if ($@) {\n>        $term = new FakeTerm \"$@: going non-interactive\";\n> }\n> )\n>\n> (in the meantime, I'll add --confirm never to my script)\n\nActually, FakeTerm is only triggered if Term::ReadLine is not\navailable. The \"going non-interactive\" message is misleading in this\ncase, as it has nothing to do with whether stdin is a tty or not.\n\nj.\n"},{"id":"109365","messageId":"76718490903250904q3ca9f20ak7288e49e226bb9fb@mail.gmail.com","threadId":"18529","inReplyTo":"vpqiqlyj64o.fsf@bauges.imag.fr","subject":"Re: [BUG] Infinite loop in git send-email if ran non-interactively.","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-03-25T16:04:41Z","receivedAt":"2009-03-25T16:04:41Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Wed, Mar 25, 2009 at 5:36 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:\n> Hi,\n>\n> I've been hit by c1f2aa45b (send-email: add --confirm option and\n> configuration setting) running git send-email from a cron job.\n\nBTW, can you provide the details on how you are invoking send-email?\n\nHave stdin/stdout/stderr been redirected? What arguments are you\ngiving it? And is this Vixie cron?\n\nThanks,\n\nj.\n"},{"id":"109371","messageId":"vpq4oxh8tb8.fsf@bauges.imag.fr","threadId":"18529","inReplyTo":"76718490903250904q3ca9f20ak7288e49e226bb9fb@mail.gmail.com","subject":"Re: [BUG] Infinite loop in git send-email if ran non-interactively.","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@imag.fr","sentAt":"2009-03-25T16:23:55Z","receivedAt":"2009-03-25T16:23:55Z","isPatch":false,"sender":{"key":"git@matthieu-moy.fr","avatar":"https://avatars.githubusercontent.com/u/14709?v=4"},"body":"Jay Soffian <jaysoffian@gmail.com> writes:\n\n> On Wed, Mar 25, 2009 at 5:36 AM, Matthieu Moy <Matthieu.Moy@imag.fr> wrote:\n>> Hi,\n>>\n>> I've been hit by c1f2aa45b (send-email: add --confirm option and\n>> configuration setting) running git send-email from a cron job.\n>\n> BTW, can you provide the details on how you are invoking send-email?\n\npatches=$(git format-patch [...])\n[...]\ngit send-email --to \"$to\" --from \"$from\" $patches\n\n> Have stdin/stdout/stderr been redirected?\n\nstdout and stderr are redirected to a file. stdin is not (I don't know\nexactly what cron sets it to).\n\n> What arguments are you giving it? And is this Vixie cron?\n\nThe \"cron\" package in Debian etch (oldstable now).\n\nThanks,\n\n-- \nMatthieu\n"},{"id":"109370","messageId":"76718490903250923u5f7a84e8ma6093b1434b36172@mail.gmail.com","threadId":"18529","inReplyTo":"76718490903250903t530983abi8a641e6b7aee6c0@mail.gmail.com","subject":"Re: [BUG] Infinite loop in git send-email if ran non-interactively.","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2009-03-25T16:23:56Z","receivedAt":"2009-03-25T16:23:56Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Wed, Mar 25, 2009 at 12:03 PM, Jay Soffian <jaysoffian@gmail.com> wrote:\n> Actually, FakeTerm is only triggered if Term::ReadLine is not\n> available. The \"going non-interactive\" message is misleading in this\n> case, as it has nothing to do with whether stdin is a tty or not.\n\nSorry, that's not true. Apparently the non-interactive test is not\nworking properly in this case.\n\nj.\n"}]}