{"thread":{"id":"10031","subject":"[PATCH 1/2] git-add--interactive: Allow Ctrl-D to exit","startedAt":"2007-09-26T13:56:19Z","lastAt":"2007-09-26T13:56:19Z","messageCount":1,"participants":["Jean-Luc Herren"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"54101","messageId":"46FA6503.5040708@gmx.ch","threadId":"10031","inReplyTo":null,"subject":"[PATCH 1/2] git-add--interactive: Allow Ctrl-D to exit","fromName":"Jean-Luc Herren","fromEmail":"jlh@gmx.ch","sentAt":"2007-09-26T13:56:19Z","receivedAt":"2007-09-26T13:56:19Z","isPatch":true,"sender":{"key":"jlh@gmx.ch","avatar":null},"body":"Hitting Ctrl-D (EOF) is a common way to exit shell-like tools.\nWhen in a sub-menu it will still behave as if an empty line had\nbeen entered, carrying out the action on the selected items and\nreturning to the previous menu.\n\nSigned-off-by: Jean-Luc Herren <jlh@gmx.ch>\n---\n git-add--interactive.perl |    7 ++++++-\n 1 files changed, 6 insertions(+), 1 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex 7921cde..f9e9f02 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -213,7 +213,11 @@ sub list_and_choose {\n \t\t\tprint \">> \";\n \t\t}\n \t\tmy $line = <STDIN>;\n-\t\tlast if (!$line);\n+\t\tif (!$line) {\n+\t\t\tprint \"\\n\";\n+\t\t\t$opts->{ON_EOF}->() if $opts->{ON_EOF};\n+\t\t\tlast;\n+\t\t}\n \t\tchomp $line;\n \t\tmy $donesomething = 0;\n \t\tfor my $choice (split(/[\\s,]+/, $line)) {\n@@ -791,6 +795,7 @@ sub main_loop {\n \t\t\t\t\t     SINGLETON => 1,\n \t\t\t\t\t     LIST_FLAT => 4,\n \t\t\t\t\t     HEADER => '*** Commands ***',\n+\t\t\t\t\t     ON_EOF => \\&quit_cmd,\n \t\t\t\t\t     IMMEDIATE => 1 }, @cmd);\n \t\tif ($it) {\n \t\t\teval {\n-- \n1.5.3\n"}]}