Misbehavior with constants and bash script

2018-11-19 Thread Alexander Reintzsch
Hello, I think I have found some unexpected behavior related to constants in bash scripts. I have attached the short proof of concept bash script. Usually bash scripts continue when they face an error with one command but this script shows some weired behavior. It exits all the functions it has c

Misbehavior with constants and bash script

2018-11-19 Thread Alexander Reintzsch
Hello, I think I have found some unexpected behavior related to constants in bash scripts. Here is a bash script as a short proof of concept. #!/bin/bash function foo { echo "A" declare -r vconst="I am fixed." echo "B" declare vconst="new value" echo "C"

Re: Misbehavior with constants and bash script

2018-11-19 Thread Chet Ramey
On 11/19/18 3:04 PM, Alexander Reintzsch wrote: > Hello, > > I think I have found some unexpected behavior related to constants in > bash scripts. I have attached the short proof of concept bash script. > > Usually bash scripts continue when they face an error with one command > but this script s

Re: Misbehavior with constants and bash script

2018-11-19 Thread Quentin L'Hours
Hi Chet, On 2018-11-19 03:38 PM, Chet Ramey wrote: > When the assignment is used as an argument to `declare', it causes the > declare command to fail, but it's not a variable assignment error, so > the script simply continues as with any other failed command. I remembered this email thread about

Re: Misbehavior with constants and bash script

2018-11-19 Thread Chet Ramey
On 11/19/18 7:06 PM, Quentin L'Hours wrote: > Hi Chet, > > On 2018-11-19 03:38 PM, Chet Ramey wrote: >> When the assignment is used as an argument to `declare', it causes the >> declare command to fail, but it's not a variable assignment error, so >> the script simply continues as with any other f