Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14828

Misbehavior with constants and bash script

From Alexander Reintzsch <Alexander.Reintzsch@netsystem.de>
Newsgroups gnu.bash.bug
Subject Misbehavior with constants and bash script
Date 2018-11-19 20:04 +0000
Message-ID <mailman.4270.1542662930.1284.bug-bash@gnu.org> (permalink)

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

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 called without executing the remaining commands and the continues
to run in the top scope of the script.

This only happens when a constant declared with
declare -r myConst="myConstantValue"
is attempted to be redefined using
myConst="new value"
but not with
declare myConst="new value"

This behavior doesn't seem right.

I have tried this on Ubuntu 16.04 LTS with bash version
GNU bash, Version 4.3.48(1)-release (x86_64-pc-linux-gnu)

Cheers,
Alex

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Misbehavior with constants and bash script Alexander Reintzsch <Alexander.Reintzsch@netsystem.de> - 2018-11-19 20:04 +0000

csiph-web