An array variable created by export/readonly builtins inside a function becomes a locale variable to that function unexpectedly

2015-11-28 Thread ziyunfei
$ ksh -c 'foo() { readonly a=(1);echo a=$a; }; foo; echo a=$a' a=1 a=1 $ bash -c 'foo() { readonly a=(1);echo a=$a; }; foo; echo a=$a' # a becomes a local variable a=1 a=

bash-4.4-beta hangs when running 'set --help'

2015-10-27 Thread ziyunfei

The character can also be an "IFS whitespace character"

2015-10-20 Thread ziyunfei
Quoting from the bash manual: "If IFS has a value other than the default, then sequences of the whitespace characters *space and tab* are ignored at the beginning and end of the word, as long as the whitespace character is in the value of IFS (an IFS whitespace character)." If this is true, t

Misused term "subshell" in §3.3 of the Bash Manual

2015-09-21 Thread ziyunfei
"Functions may be exported so that *subshells* automatically have them defined with the -f option to the export builtin" Technically, a child shell process forked/execed by the current shell is not a real subshell, am I right?

Re: [Help-bash] Why BASH_SUBSHELL behaves differently in () and <()?

2015-09-17 Thread ziyunfei
> The expansion is being done in the parent shell, rather than the subshell. But as you said in http://lists.gnu.org/archive/html/help-bash/2015-04/msg00010.html BASHPID is expanded in the subshell, so BASH_SUBSHELL must also be like that. And I found a comment which says: "make the child early,

SHLVL is a random string (uninitialized string in C) when its true value is "1000"

2015-09-16 Thread ziyunfei
$ SHLVL=998 bash -c 'echo $SHLVL' 999 $ SHLVL=999 bash -c 'echo $SHLVL' $ SHLVL=999 bash -c 'echo -n "$SHLVL" | hexdump' 0b 01 $ SHLVL=999 bash -c 'echo -n "$SHLVL" | hexdump' 0f 01 $ SHLVL=999 bash -c 'echo -n "$SHLVL" | hexdump' 04 01 $ SHLVL=1000 bash -c 'echo $SHLVL' bash: warning: shell level

`pwd' returns a dot

2015-09-16 Thread ziyunfei
$ cd / $ PWD=. bash -c pwd . $ PWD=. ksh -c pwd / Posix says that pwd shouldn't return the filenames dot or dot-dot. http://pubs.opengroup.org/onlinepubs/9699919799/utilities/pwd.html

Bash crashes on `exec -c'

2015-09-15 Thread ziyunfei
$ echo $BASH_VERSION 4.2.45(2)-release $ echo :>test $ chmod +x test $ exec -c ./test [1]15650 segmentation fault bash

`foo=1 declare -r foo' prints an error message but its exit status is zero

2015-09-08 Thread ziyunfei
$ foo=1 declare -r foo bash: foo: readonly variable $ echo $? 0 $ echo $foo 1 Is this a bug? $ bar=1 readonly bar; # throw an error in Bash 4.2, fixed in Bash 4.3

Re: \? is missing in "3.1.2.4 ANSI-C Quoting" in Bash Reference Manual

2015-09-03 Thread ziyunfei
On Sep 4, 2015, at 3:07 AM, Chet Ramey wrote: > I guess I see what you're saying: that bash removes the backslash quoting > the `?' when processing $'...' but leaves backslashes escaping other > characters not listed in the description of $'...' unchanged. I can add > that to the documentation.

Re: \? is missing in "3.1.2.4 ANSI-C Quoting" in Bash Reference Manual

2015-09-02 Thread ziyunfei
d octal escapes beginning with ‘\0’ may contain up to four digits.” but it isn't documented in https://www.gnu.org/software/bash/manual/html_node/ANSI_002dC-Quoting.html correspondingly after \’ and \”. Please correct me if I am missing the point. 在 2015年9月2日,下午11:32,Chet Ramey 写道:

\? is missing in "3.1.2.4 ANSI-C Quoting" in Bash Reference Manual

2015-09-02 Thread ziyunfei
bash-4.3$ echo $'\?' ? \? should be added there.