delcare -a on a nameref in a function modifies nameref instead of target

2018-07-17 Thread Grisha Levit
At global scope this works as expected: $ declare -n ref=var; declare -a ref=(X); declare -p ref var declare -n ref="var" declare -a var=([0]="X") But in a function, we end up with the nameref variable having both the `a' and `n' attributes and nothing in the target: $ f() { declare -n ref=var;

test -v and environment variable names with subscripts

2018-07-17 Thread Grisha Levit
When there is a variable with a name that includes a subscript in the environment, test -v looks at that variable rather than an array with that subscript. I just posted about two ways [1] [2] to create variables like `var[0]=X' and if both of those methods are fixed than this report might be

Re: segfault when converting local indexed to associative array

2018-07-17 Thread Chet Ramey
On 7/17/18 1:55 PM, Grisha Levit wrote: > $ echo $BASH_VERSION > 4.4.23(1)-release > $ f() { declare -a a; declare -A a; declare -p a; }; f > bash: declare: a: cannot convert indexed to associative array > declare -aA a > Segmentation fault: 11 > > This behavior is still present in the devel

temp env allows variables that look like array subscripts

2018-07-17 Thread Grisha Levit
Usually, an assignment preceding a command that would create a variable with an invalid name is rejected and treated like a command name: $ 1=X : bash: 1=X: command not found But when the variable name looks (sort of) like an array subscript assignment, it is accepted and an oddly named variable

namerefs and environment variable names with subscripts

2018-07-17 Thread Grisha Levit
The following commands: declare -n r=v[0] v=(X); r=Y declare -p ${!v*} printf "%s: <%s>\n" "r" "$r" "v" "$v" Will normally produce the following output: declare -a v=([0]="Y") r: v: However, if we start bash with `v[0]' already in the environment, such as with:

segfault when converting local indexed to associative array

2018-07-17 Thread Grisha Levit
$ echo $BASH_VERSION 4.4.23(1)-release $ f() { declare -a a; declare -A a; declare -p a; }; f bash: declare: a: cannot convert indexed to associative array declare -aA a Segmentation fault: 11 This behavior is still present in the devel branch.

Re: About bash_syslog_histrory Function!

2018-07-17 Thread Chet Ramey
On 7/17/18 4:03 AM, sunhui...@unionpay.com wrote: > Hi: >I found the orginal bash_syslog_history has three flaws: > 1、 Ingore the texts that length exceed SYSLOG_MAXLEN,however in our > environment ,we have a lot of db2 command line which exceed SYSLOG_MAXLEN; > 2、only get PID

Re: DIRSTACK[0] contains literal "~"

2018-07-17 Thread Chet Ramey
On 7/12/18 7:38 PM, jeremy.richa...@ngc.com wrote: > Bash Version: 4.2 > Patch Level: 46 > Release Status: release > > Description: > I noticed some strange behavior in the DIRSTACK variable (used in > pushd/popd). > `declare -p DIRSTACK` > shows the list of current directories on