git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/2] git-add--interactive: Allow Ctrl-D to exit

From
JHJean-Luc Herren <jlh@gmx.ch>
Date
Sep 26, 2007, 13:56 UTC
Message-ID
<46FA6503.5040708@gmx.ch>

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>
---
 git-add--interactive.perl |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)
diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index 7921cde..f9e9f02 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -213,7 +213,11 @@ sub list_and_choose {
 			print ">> ";
 		}
 		my $line = <STDIN>;
-		last if (!$line);
+		if (!$line) {
+			print "\n";
+			$opts->{ON_EOF}->() if $opts->{ON_EOF};
+			last;
+		}
 		chomp $line;
 		my $donesomething = 0;
 		for my $choice (split(/[\s,]+/, $line)) {
@@ -791,6 +795,7 @@ sub main_loop {
 					     SINGLETON => 1,
 					     LIST_FLAT => 4,
 					     HEADER => '*** Commands ***',
+					     ON_EOF => \&quit_cmd,
 					     IMMEDIATE => 1 }, @cmd);
 		if ($it) {
 			eval {
-- 
1.5.3
Message 1 of 1 in “git-add--interactive: Allow Ctrl-D to exit”
  1. 1/2 git-add--interactive: Allow Ctrl-D to exitJean-Luc Herren, Sep 26, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.