Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #15079 > unrolled thread

$? is -1

Started bybashbug@jonkmans.nl
First post2019-07-05 11:57 +0200
Last post2019-07-05 11:57 +0200
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  $? is -1 bashbug@jonkmans.nl - 2019-07-05 11:57 +0200

#15079 — $? is -1

Frombashbug@jonkmans.nl
Date2019-07-05 11:57 +0200
Subject$? is -1
Message-ID<mailman.200.1562320741.2688.bug-bash@gnu.org>
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

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web