[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] Is `readonly` too strict?
From: |
Peng Yu |
Subject: |
[Help-bash] Is `readonly` too strict? |
Date: |
Thu, 22 Feb 2018 00:58:09 -0600 |
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
--
Regards,
Peng
- [Help-bash] Is `readonly` too strict?,
Peng Yu <=