readline fails to understand options.

2018-12-20 Thread Bize Ma
This works:

 $ bind 'set enable-bracketed-paste on'; bind -v | grep 'bracketed'
 set enable-bracketed-paste on

However, almost any variation of the parameter "on" is not understood by
readline:

 $ bind 'set enable-bracketed-paste on .'; bind -v | grep 'bracketed'
 set enable-bracketed-paste off

 $ bind 'set enable-bracketed-paste "on"'; bind -v | grep 'bracketed'
 set enable-bracketed-paste off

Without any error or warning !!

It appears to fall to default value, while this:

 $ bind 'set bell-style on' ; bind -v | grep 'bell-style'
 set bell-style audible

 $ bind 'set bell-style onf' ; bind -v | grep 'bell-style'
 set bell-style audible

Stays at its last value.

It seems that the parser for this options is unable to process anything
after a valid parameter. And it doesn't emit an error or warning either.

Since the parser needs some improvement: Could it be possible to add the
capability to detect  a `#` after the options as a comment ?

Please read:
https://unix.stackexchange.com/questions/487037/why-is-my-readline-inputrc-configuration-being-ignored/487285#487285


Bash-5.0-rc1 available

2018-12-20 Thread Chet Ramey
The first release candidate of bash-5.0 is now available with the URLs

ftp://ftp.cwru.edu/pub/bash/bash-5.0-rc1.tar.gz
ftp://ftp.gnu.org/pub/gnu/bash/bash-5.0-rc1.tar.gz

and from the bash-5.0-testing branch in the bash git repository   
(http://git.savannah.gnu.org/cgit/bash.git/log/?h=bash-5.0-testing).  

This tar file includes the formatted documentation (you should be able to
generate updated versions yourself).

This release fixes several outstanding bugs in bash-4.4 and introduces several
new features.  The most significant bug fixes are an overhaul of how
nameref variables resolve and a number of potential out-of-bounds memory
errors discovered via fuzzing. There are a number of changes to the
expansion of $@ and $* in various contexts where word splitting is not
performed to conform to a Posix standard interpretation, and additional
changes to resolve corner cases for Posix conformance.

The most notable new features are several new shell variables: BASH_ARGV0,
EPOCHSECONDS, and EPOCHREALTIME. The `history' builtin can remove ranges of
history entries and understands negative arguments as offsets from the end
of the history list. There is an option to allow local variables to inherit
the value of a variable with the same name at a preceding scope. There is
a new shell option that, when enabled, causes the shell to attempt to
expand associative array subscripts only once (this is an issue when they
are used in arithmetic expressions).  The `globasciiranges' shell option
is now enabled by default; it can be set to off by default at configuration
time.

There are a few incompatible changes between bash-4.4 and bash-5.0. The
changes to how nameref variables are resolved means that some uses of
namerefs will behave differently, though I have tried to minimize the
compatibility issues. By default, the shell only sets BASH_ARGC and
BASH_ARGV at startup if extended debugging mode is enabled; it was an
oversight that it was set unconditionally and caused performance issues
when scripts were passed large numbers of arguments.

`bashbug' may be used to report bugs with this version.  It will send
mail to chet.ra...@case.edu if the shell's `release status' is alpha or
beta.

As always, thanks for your help.

Chet

+== CHANGES ==+
This document details the changes between this version, bash-5.0-rc1, and
the previous version, bash-5.0-beta2.

1. Changes to Bash

a. Fix to initial word completion detection code.

b. Fixed a bug that caused issues with assignment statements containing ^A in
   the value assigned when IFS contains ^A.

c. Added a fallback to fnmatch() when strcoll can't correctly deal with
   bracket expression character equivalence classes.

d. Fixed a bug that caused $BASH_COMMAND to contain the trap handler command
   when running a trap handler containing [[ or (( commands.

e. Fixed a bug that caused nameref assignments in the temporary environment
   to potentially create variables with invalid names.

f. Fixed a bug that caused `local -' to turn off alias expansion in scripts.

g. Fixed a parser issue with a command string containing EOF after an invalid
   command as an argument to a special builtin not causing a posix-mode shell
   to exit.

h. Made a slight change to the FNV-1 string hash algorithm used for associative
   arrays (corrected the initial seed).

2. Changes to Readline

3. New Features in Bash

a. The `select' command now supports command forms without a word list
   following `in'.

4. New Features in Readline

--
This document details the changes between this version, bash-5.0-beta2, and
the previous version, bash-5.0-beta.

1. Changes to Bash

a. Fixed a bug that could cause a seg fault while parsing a subshell command
   inside a command substitution.

b. Fixed several small memory leaks uncovered by coverity.

c. Fixed a problem with command substitution inside an interactive shell that
   could cause the parent to receive a SIGHUP.

d. Fixed a problem with using `*' and `@' as subscripts when assigning values
   to an associative array with assoc_expand_once enabled.

e. Fixed a bug that could cause a huge memory allocation when completing a
   word beginning with an invalid tilde expansion.

f. Cleaned up some incompatiblities with bash-4.4 when expanding indexed array
   subscripts used in arithmetic expansions when assoc_expand_once is enabled.

g. The ${parameter@a} expansion will display attributes even if `parameter' is
   unset.

h. Fixed a bug that caused the output of `set' to cut off some variables before
   printing the value.

i. Treat a failure to assign a variable when using the ${x:=value} expansion
   as an expansion error, so non-interactive posix-mode shells exit

j. Fixed a problem when expanding $* in a context where word splitting is not
   performed when IFS is NULL.

k. Temp files used to store here documents are forced readable, no matter what
   

Re: Error on arithmetic evaluation of `~0`.

2018-12-20 Thread Andreas Schwab
On Dez 20 2018, Greg Wooledge  wrote:

> The issue you're reporting appears to be present in arithmetic contexts
> in general, not only arrays:
>
> wooledg:~$ echo $((~0))
> bash: /home/wooledg: syntax error: operand expected (error token is 
> "/home/wooledg")

This has been fixed in bash 5.0.

> It appears that bash is performing tilde expansion when there's no
> whitespace in front of the tilde, or bitwise negation if there is
> whitespace.

POSIX says that arithmetic expressions are not subject to tilde
expansion.  IMHO bash shouldn't do that either for indexed array
subscripts, since they are arithmetic expressions.

Andreas.

-- 
Andreas Schwab, SUSE Labs, sch...@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."



Re: Error on arithmetic evaluation of `~0`.

2018-12-20 Thread Greg Wooledge
On Wed, Dec 19, 2018 at 10:31:36PM -0500, Bize Ma wrote:
> It is also interesting that this fails:
> 
> var=hello; echo "${var[ ~0]}"
> bash: var: bad array subscript
> 
> Isn't `var[0]` valid and equivalent to `var` ?

Yes, but ~0 is not 0.

wooledg:~$ echo $(( ~0))
-1

The issue you're reporting appears to be present in arithmetic contexts
in general, not only arrays:

wooledg:~$ echo $((~0))
bash: /home/wooledg: syntax error: operand expected (error token is 
"/home/wooledg")

It appears that bash is performing tilde expansion when there's no
whitespace in front of the tilde, or bitwise negation if there is
whitespace.