[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Local variable names clash with global read-only variable names.
From: |
andrej |
Subject: |
Local variable names clash with global read-only variable names. |
Date: |
Tue, 28 Apr 2020 20:14:28 +0200 |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -march=x86-64 -mtune=generic -O2 -pipe -fno-plt
-DDEFAULT_PATH_VALUE='/usr/local/sbin:/usr/local/bin:/usr/bin'
-DSTANDARD_UTILS_PATH='/usr/bin' -DSYS_BASHRC='/etc/bash.bashrc'
-DSYS_BASH_LOGOUT='/etc/bash.bash_logout' -DNON_INTERACTIVE_LOGIN_SHELLS
-Wno-parentheses -Wno-format-security
uname output: Linux charon 5.6.4-arch1-1-user-regd #1 SMP PREEMPT Fri, 17 Apr
2020 12:06:27 +0000 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.0
Patch Level: 16
Release Status: release
Description:
Global and local variable namespaces are distinct in the most common case:
f() { local x=a; }
x=b
f
echo "$x" # still 'b', as expected
However, this^^^ example stops working when $x is declared read-only:
Repeat-By:
f() { local x=a; }
declare -r x
f # bash: local: x: readonly variable
This^^^ should not fail; it hinders reusability of shell functions and makes
them context-dependent.
- Local variable names clash with global read-only variable names.,
andrej <=