bug-bash
[Top][All Lists]
Advanced

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

Re: Aborting prompt with Ctrl-c sets exit status variable ($?) to 130


From: Dennis Williamson
Subject: Re: Aborting prompt with Ctrl-c sets exit status variable ($?) to 130
Date: Wed, 4 Jun 2014 14:28:43 -0500

On Jun 4, 2014 2:23 PM, "Jens Stimpfle" <address@hidden> wrote:
>
> Hi, please Cc: me as I'm not subscribed.
>
> When I abort a bash prompt using Ctrl-c, the $? variable is set to 130
> just as if a job had been aborted. To illustrate, some terminal
> contents:
>
> address@hidden:~$ echo Hello
> Hello
> address@hidden:~$ echo $?
> 0
> address@hidden:~$ echo H^C
> address@hidden:~$ echo $?
> 130
> address@hidden:~$
>
> My feeling is that aborting a prompt should not change the $? variable.
> From the docs:
>
>  ?      Expands to the exit status of the most recently executed
>         foreground pipeline.
>
> I don't think the prompt counts as a pipeline (it can't be job
> controlled).
>
> This behaviour is particularly annoying when I log out from an SSH
> session using Ctrl-c Ctrl-d:
>
> address@hidden:~$ ssh riese
> [...]
> address@hidden:~$ foo^C
> address@hidden:~$ logout
> Connection to riese closed.
> address@hidden:~$ echo $?
> 130
> address@hidden:~$
>
> What are your thoughts?
>

130 is 128 + 2

Signal 2 is SIGINT which is ctrl-c


reply via email to

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