Path: csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail From: Alexander Reintzsch Newsgroups: gnu.bash.bug Subject: Misbehavior with constants and bash script Date: Mon, 19 Nov 2018 20:04:21 +0000 Lines: 91 Approved: bug-bash@gnu.org Message-ID: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="K4FuowRCbC3PK1A9VBcmp4bAYhn8CleA5" X-Trace: usenet.stanford.edu 1542662931 26571 208.118.235.17 (19 Nov 2018 21:28:51 GMT) X-Complaints-To: action@cs.stanford.edu To: "bug-bash@gnu.org" Envelope-to: bug-bash@gnu.org Thread-Topic: Misbehavior with constants and bash script Thread-Index: AQHUgEMP54SJp6hR+0aak96ssHT2kQ== Accept-Language: de-DE, en-US Content-Language: de-DE X-MS-Has-Attach: yes X-MS-TNEF-Correlator: user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 x-ms-exchange-messagesentrepresentingtype: 1 x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.121.1.226] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 85.13.147.64 X-Mailman-Approved-At: Mon, 19 Nov 2018 16:28:50 -0500 X-Content-Filtered-By: Mailman/MimeDel 2.1.21 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14828 --K4FuowRCbC3PK1A9VBcmp4bAYhn8CleA5 From: Alexander Reintzsch To: bug-bash@gnu.org Message-ID: <857e2280-38c5-344e-1916-17a6c6c61b02@netsystem.de> Subject: Misbehavior with constants and bash script Content-Type: multipart/mixed; boundary="------------92A3DAA5A66C3A209D138F8E" --------------92A3DAA5A66C3A209D138F8E Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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=3D"myConstantValue" is attempted to be redefined using myConst=3D"new value" but not with declare myConst=3D"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 --------------92A3DAA5A66C3A209D138F8E Content-Type: text/plain; charset=UTF-8; name="poc.bash" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="poc.bash" IyEvYmluL2Jhc2gKZnVuY3Rpb24gZm9vCnsKCWVjaG8gIkEiCglkZWNsYXJlIC1yIHZjb25z dD0iSSBhbSBmaXhlZC4iCgllY2hvICJCIgoJZGVjbGFyZSB2Y29uc3Q9Im5ldyB2YWx1ZSIK CWVjaG8gIkMiCgl1bnNldCB2Y29uc3QKCWVjaG8gIkQiCgl2Y29uc3Q9Im5ldyB2YWx1ZSIK CWVjaG8gIkUiCn0KCmZ1bmN0aW9uIGJhcgp7CgllY2hvICJiZWZvcmUgZm9vIgoJZm9vCgll Y2hvICJhZnRlciBmb28iCn0KCmZ1bmN0aW9uIGJ1enoKewoJZWNobyAiYmVmb3JlIGJhciIK CWJhcgoJZWNobyAiYWZ0ZXIgYmFyIgp9Cgpmb28KYmFyCmJ1enoKZWNobyAidGhlIGxhc3Qg bGluZSIK --------------92A3DAA5A66C3A209D138F8E Content-Type: text/x-vcard; charset=utf-8; name="alexander_reintzsch.vcf" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="alexander_reintzsch.vcf" begin:vcard fn:Alexander Reintzsch n:Reintzsch;Alexander org:NetSystem GmbH;Technik adr;quoted-printable:;;Zollstra=3DC3=3D9Fe 4;Wuppertal;Nordrhein-Westfale= n;42103;Deutschland email;internet:alexander.reintzsch@netsystem.de title:Softwaree Engineer tel;work:+49 202 705398 148 tel;fax:+49 202 705398 448 x-mozilla-html:FALSE url:http://www.netsystem.de version:2.1 end:vcard --------------92A3DAA5A66C3A209D138F8E-- --K4FuowRCbC3PK1A9VBcmp4bAYhn8CleA5 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iEYEARECAAYFAlvzF0QACgkQdjvM+NoqVQuv9gCfUx0E6WOgRsq804aAkv1BNBMf lf0An28+dXq8JuUxzveyNmec4j8P+ZRD =snTr -----END PGP SIGNATURE----- --K4FuowRCbC3PK1A9VBcmp4bAYhn8CleA5--