bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Misbehavior with constants and bash script


From: Alexander Reintzsch
Subject: Misbehavior with constants and bash script
Date: Mon, 19 Nov 2018 20:04:21 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1

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

Attachment: poc.bash
Description: Text document

Attachment: alexander_reintzsch.vcf
Description: Vcard

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]