help-bash
[Top][All Lists]
Advanced

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

Re: Exiting the "read" builtin with trapped ^C


From: Stan Marsh
Subject: Re: Exiting the "read" builtin with trapped ^C
Date: Mon, 22 Jun 2026 08:39:26 -0600

From:   Greg Wooledge
Subject: Re: Exiting the "read" builtin with trapped ^C
Date:   Mon, 22 Jun 2026 10:28:21 -0400

>On Mon, Jun 22, 2026 at 08:06:24 -0600, Stan Marsh wrote:
>> Note that similar things happen with QUIT. In general, I'd like a good
>> way to have 'read' exit sensibly when I hit ^C (or ^\).
>> 
>> Is there a better way?

>The obvious answer would be "don't trap SIGINT".  Can you explain why
>you're doing that?

So that the script will continue after the ^C, of course.

>If the answer is something like "I want the user to be able to skip this
>one question by pressing Ctrl-C, without aborting the entire script",
>then the usual interface design would be to have them type something like
>"q" as a response that means "skip this question" (assuming that "q"
>is not a valid response -- e.g. the question expects a numeric input).

Your response is reasonable, but, as usual, the devil is in the
details.

There are reasons why I want to do it this way.

In any case, I just find it strange that 'read' doesn't exit when you
^C it (when there is an active trap on INT).

=================================================================================
Please do not send me replies to my posts on the list.
I always read the replies via the web archive, so CC'ing to me is unnecessary.

When responding to my posts, please try to refrain from giving bureaucratic
answers.  If you have nothing useful to say, then just click Next and go on.



reply via email to

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