Re: AW: Misbehavior with constants and bash script

2018-11-20 Thread Chet Ramey
On 11/20/18 6:38 AM, Alexander Reintzsch wrote: > and if I add an empty command after the assignment statement it behaves as > expected. > > echo "A" > declare -r vconst="I am fixed." > echo "B" > vconst="new value" : # please note the : at the end. (no operation command) > echo "C" # now printe

AW: Misbehavior with constants and bash script

2018-11-20 Thread Alexander Reintzsch
Hello Chet, thank you for your help and pointing to the posix behavior. Quoting https://www.gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html "[...] A non-interactive shell exits with an error status if a variable assignment error occurs when no command name follows the assignment sta

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

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 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

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"

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