Peng Yu
2018-02-22 06:58:09 UTC
Hi,
Running `main.sh` shows an error. But `x` is set for `script.sh` not
`main.sh`. So I think that there should not be an error message. Is
`readonly` interpreted too strictly in bash?
$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:
set -v
readonly x
x=abc ./script.sh
$ cat script.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:
echo "$x"
$ ./main.sh
readonly x
x=abc ./script.sh
./main.sh: line 6: x: readonly variable
Running `main.sh` shows an error. But `x` is set for `script.sh` not
`main.sh`. So I think that there should not be an error message. Is
`readonly` interpreted too strictly in bash?
$ cat main.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:
set -v
readonly x
x=abc ./script.sh
$ cat script.sh
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:
echo "$x"
$ ./main.sh
readonly x
x=abc ./script.sh
./main.sh: line 6: x: readonly variable
--
Regards,
Peng
Regards,
Peng