[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" <debian@jstimpfle.de> 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:
>
> jfs@knirps:~$ echo Hello
> Hello
> jfs@knirps:~$ echo $?
> 0
> jfs@knirps:~$ echo H^C
> jfs@knirps:~$ echo $?
> 130
> jfs@knirps:~$
>
> 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:
>
> jfs@knirps:~$ ssh riese
> [...]
> jfs@riese:~$ foo^C
> jfs@riese:~$ logout
> Connection to riese closed.
> jfs@knirps:~$ echo $?
> 130
> jfs@knirps:~$
>
> What are your thoughts?
>
130 is 128 + 2
Signal 2 is SIGINT which is ctrl-c