Re: local -r issue in conjunction with trap

2022-07-18 Thread Chet Ramey
On 7/17/22 6:48 PM, Koichi Murase wrote: 1) "set -e" is set. 2) The code is executed from a script file. 3) Shadowing of local readonly variables is attempted in a trap handler. This exact set of conditions, plus the requirement that it must be an exit trap handler and the `exit' builtin must

Re: local -r issue in conjunction with trap

2022-07-18 Thread Chet Ramey
On 7/17/22 6:48 PM, Koichi Murase wrote: 2022年7月18日(月) 6:40 Chet Ramey : On 7/15/22 7:06 PM, Koichi Murase wrote: We can shadow local readonly variables. What we cannot are global readonly variables. It seems to me a bug. It's not a bug. Bash-2.04 introduced behavior to disallow local variab

Re: local -r issue in conjunction with trap

2022-07-17 Thread Koichi Murase
2022年7月18日(月) 6:40 Chet Ramey : > On 7/15/22 7:06 PM, Koichi Murase wrote: > > We can shadow local readonly variables. What we cannot are global > > readonly variables. > > > > It seems to me a bug. > > It's not a bug. Bash-2.04 introduced behavior to disallow local variables > with the same name a

Re: local -r issue in conjunction with trap

2022-07-17 Thread Chet Ramey
On 7/15/22 7:06 PM, Koichi Murase wrote: 2022年7月16日(土) 7:28 Lawrence Velázquez : You can't shadow a readonly variable: https://lists.gnu.org/archive/html/bug-bash/2019-03/msg00152.html https://lists.gnu.org/archive/html/bug-bash/2019-03/msg00153.html https://lists.gnu.org/archive/html/bug-bash/

Re: local -r issue in conjunction with trap

2022-07-16 Thread Dale R. Worley
Robert Stoll writes: > test1 # works as exit happens outside of test1 > test2 # fails with ./src/test.sh: line 6: local: readonlyVar: readonly > variable Beware that you haven't specified what you mean by "works" and "fails". I assume from the context that "fails" means "produces an error messag

Re: local -r issue in conjunction with trap

2022-07-16 Thread Robert Elz
Date:Fri, 15 Jul 2022 16:13:40 + (UTC) From:Robert Stoll Message-ID: <1549965963.26496.1657901620717.javamail.zim...@tegonal.com> | Unfortunately I have never built bash on my own and it would probably | take me too much time to do it. It probably wouldn't, f

Re: local -r issue in conjunction with trap

2022-07-15 Thread Lawrence Velázquez
On Fri, Jul 15, 2022, at 7:06 PM, Koichi Murase wrote: > 2022年7月16日(土) 7:28 Lawrence Velázquez : >> You can't shadow a readonly variable: >> >> https://lists.gnu.org/archive/html/bug-bash/2019-03/msg00152.html >> https://lists.gnu.org/archive/html/bug-bash/2019-03/msg00153.html >> https://lists.gnu

Re: local -r issue in conjunction with trap

2022-07-15 Thread Koichi Murase
2022年7月16日(土) 7:28 Lawrence Velázquez : > You can't shadow a readonly variable: > > https://lists.gnu.org/archive/html/bug-bash/2019-03/msg00152.html > https://lists.gnu.org/archive/html/bug-bash/2019-03/msg00153.html > https://lists.gnu.org/archive/html/bug-bash/2020-04/msg00201.html > https://lis

Re: local -r issue in conjunction with trap

2022-07-15 Thread Lawrence Velázquez
On Fri, Jul 15, 2022, at 6:26 PM, Lawrence Velázquez wrote: > it's worth noting that the trap command runs in the context > from which the shell exits Sorry, this might not be clear. Here I am referring to the command that is provided as the argument to the "trap" utility. > not the context in w

Re: local -r issue in conjunction with trap

2022-07-15 Thread Lawrence Velázquez
On Fri, Jul 15, 2022, at 12:13 PM, Robert Stoll wrote: > Following a script to reproduce the problem: > > = > > #!/usr/bin/env bash > set -e > > function trapHook(){ > echo "$1" > local -r readonlyV

local -r issue in conjunction with trap

2022-07-15 Thread Robert Stoll
Hi Unfortunately I have never built bash on my own and it would probably take me too much time to do it. Thus, I am writing to this e-mail in the hope that someone more experienced can try to reproduce it with the latest version. I do hope that my bug-report helps nonetheless to improve bash.