$ 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=
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
"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?
> 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=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
$ 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
$ 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
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
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.
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 写道:
bash-4.3$ echo $'\?'
?
\? should be added there.
12 matches
Mail list logo