Hi Bruno,

On 5/16/24 5:52 AM, Bruno Haible wrote:
> Yes, that's what I meant. Instead of "*** Stop." maybe "*** Interrupted."
> (I don't know which of the two, in English, more clearly indicates that it
> cannot be continued. On one hand, a program which received a SIGSTOP
> can be continued via SIGCONT. On the other hand, in French, "interruption"
> means a temporary stop.)

Ah, interesting. I think in English it would mostly depend on the
context. "Interruption" means you are stopping something from
progressing, but I don't think the word itself describes if it is
temporary or not. "Stop" more strongly indicates a permanent halting
of the activity, but that isn't always the case. Language is hard I
guess. :)

I've committed the attached patch since I think the return value is
more important. I'm fine with "*** Stop.", but anyone can change it if
they would like.

I modified the previous diff a bit. Since cli_exception is just an
exception hook, I think it makes the code less awkward to catch the
KeyboardInterrupt separately in another "except ..." line in main().

$ gnulib-tool --create-testdir --dir=testdir1 --single-configure stdbit-h
Module list with included dependencies (indented):
    c99
    extern-inline
[...]
  tests/test-stdbit-h.c
  tests/test-stdbool.c
executing aclocal -I glm4
^C/home/collin/.local/src/gnulib/gnulib-tool.py: *** Stop.

Collin
From 46be8fb69d76bed6cb4cc3d4ec5515adb84f033a Mon Sep 17 00:00:00 2001
From: Collin Funk <collin.fu...@gmail.com>
Date: Thu, 16 May 2024 18:26:50 -0700
Subject: [PATCH] gnulib-tool.py: Fix return value when exiting with Ctrl-C.

* pygnulib/main.py (main_with_exception_handling): Catch
KeyboardInterrupts and exit with a return code of 1.
---
 ChangeLog        | 6 ++++++
 pygnulib/main.py | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index bb2deb6766..ba52fbcdf1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-05-16  Collin Funk  <collin.fu...@gmail.com>
+
+	gnulib-tool.py: Fix return value when exiting with Ctrl-C.
+	* pygnulib/main.py (main_with_exception_handling): Catch
+	KeyboardInterrupts and exit with a return code of 1.
+
 2024-05-16  Collin Funk  <collin.fu...@gmail.com>
 
 	unsetenv tests: Update module dependencies.
diff --git a/pygnulib/main.py b/pygnulib/main.py
index b693e71d7f..68be0ba28f 100644
--- a/pygnulib/main.py
+++ b/pygnulib/main.py
@@ -1380,6 +1380,9 @@ def main_with_exception_handling() -> None:
     try:  # Try to execute
         with tempfile.TemporaryDirectory(prefix='glpy') as temporary_directory:
             main(temporary_directory)
+    except KeyboardInterrupt:
+        sys.stderr.write('%s: *** Stop.\n' % APP['name'])
+        sys.exit(1)
     except GLError as error:
         errmode = 0  # gnulib-style errors
         errno = error.errno
-- 
2.45.0

Reply via email to