bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gnulib-tool Python tracebacks after control-C


From: Collin Funk
Subject: Re: gnulib-tool Python tracebacks after control-C
Date: Wed, 15 May 2024 21:00:44 -0700
User-agent: Mozilla Thunderbird

On 5/15/24 8:45 PM, Bruno Haible wrote:
> Can you make gnulib-tool.py print a diagnostic in this case as well?
> It does not need to be exactly "caught signal SIGINT", like bash does.
> Just an indication that
>   - gnulib-tool.py
>   - is being terminated
>   - due to a signal 2.
> Preferrably formatted in the same way as the other fatal errors, i.e.
> starting with
>   '%s: *** ' % APP['name']
> 
> The exit code is nonzero (128 + 2); this is good.

Good point about the error number. I suppose we could just exit on
KeyboardInterrupt and print a message to stderr. Since after the
exception we just exit anyways something like this would work:

$ git diff .
diff --git a/pygnulib/main.py b/pygnulib/main.py
index b693e71d7f..0dea039957 100644
--- a/pygnulib/main.py
+++ b/pygnulib/main.py
@@ -1370,6 +1370,9 @@ def cli_exception(exc_type, exc_value, exc_traceback) -> 
None:
     thrown when Ctrl-C is pressed.'''
     if not issubclass(exc_type, KeyboardInterrupt):
         sys.__excepthook__(exc_type, exc_value, exc_traceback)
+    else:
+        sys.stderr.write('%s: *** Stop.\n' % APP['name'])
+        sys.exit(1)

Then using it:

$ rm -rf ../testdir1; ./gnulib-tool.py --create-testdir --dir=../testdir1 
--single-configure stdbit-h
Module list with included dependencies (indented):
    c99
    extern-inline
    gen-header
    std-gnu11
  stdbit-h
    stdbit-h-tests
    stdbool
    stdbool-tests
File list:
  lib/dummy.c
  lib/stdbit.c
  lib/stdbit.in.h
  m4/00gnulib.m4
  m4/c-bool.m4
  m4/extern-inline.m4
  m4/gnulib-common.m4
  m4/std-gnu11.m4
  m4/stdbit_h.m4
  m4/zzgnulib.m4
  tests/macros.h
  tests/test-stdbit-h.c
  tests/test-stdbool.c
executing aclocal -I glm4
^C/home/collin/.local/src/gnulib/gnulib-tool.py: *** Stop.
$ echo $?
1

Is that similar to what you were thinking of? I'm not sure what to put
for the error message. Feel free to commit something if this works for you.

Collin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]