[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
$? is -1
From: |
bashbug |
Subject: |
$? is -1 |
Date: |
Fri, 5 Jul 2019 11:57:50 +0200 (CEST) |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL
-DHAVE_CONFIG_H -I. -I../. -I.././include -I.././lib -Wdate-time
-D_FORTIFY_SOURCE=2 -g -O2 -fdebug-prefix-map=/build/bash-Det0cS/bash-4.4.18=.
-fstack-protector-strong -Wformat -Werror=format-security -Wall
-Wno-parentheses -Wno-format-security
uname output: Linux mine 4.15.0-54-generic #58-Ubuntu SMP Mon Jun 24 10:55:24
UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 4.4
Patch Level: 19
Release Status: release
Description:
Two related issues, regarding negative exit status.
First, I always thought that the exit status, $?, was in the 0-255
range.
( wait4 int argument for status masked with 0377 )
But I got a -1 in the exit status of (builtin command) bind.
Is this a bug or wanted behaviour?
Second, when ran in a subshell, the same exit status gets mapped to 255.
While logical, as -1 gets mapped to 255, it seems inconsistent.
( from the manual: "The return status is the exit status of list." )
Repeat-By:
$ bind -x "l":ls
bash: bind: l:ls: first non-whitespace character is not `"'
$ echo $?
-1
$ ( bind -x "l":ls 2>/dev/null ); echo $?
255
$ # This would have worked (but is irrelevant)
$ bind -x '"l":ls' # exit 0
$ bind l:self-insert # undo