git-add--interactive: Allow Ctrl-D to exit
Hitting Ctrl-D (EOF) is a common way to exit shell-like tools. When in a sub-menu it will still behave as if an empty line had been entered, carrying out the action on the selected items and returning to the previous menu. Signed-off-by: Jean-Luc Herren <jlh@gmx.ch> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jean-Luc Herren committed
Sep 26, 2007 at 15:56 UTC
c95c02486c4dd82f8910a8de1cb7c8f9db899995
1 file changed
+6
-1
git-add--interactive.perl
+6
-1
@@ -213,7 +213,11 @@ sub list_and_choose {
213
print ">> ";
214
}
215
my $line = <STDIN>;
216
- last if (!$line);
216
+ if (!$line) {
217
+ print "\n";
218
+ $opts->{ON_EOF}->() if $opts->{ON_EOF};
219
+ last;
220
+ }
221
chomp $line;
222
my $donesomething = 0;
223
for my $choice (split(/[\s,]+/, $line)) {
@@ -791,6 +795,7 @@ sub main_loop {
795
SINGLETON => 1,
796
LIST_FLAT => 4,
797
HEADER => '*** Commands ***',
798
+ ON_EOF => \&quit_cmd,
799
IMMEDIATE => 1 }, @cmd);
800
if ($it) {
801
eval {