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


Groups > gnu.bash.bug > #14834

AW: Misbehavior with constants and bash script

Path csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Alexander Reintzsch <Alexander.Reintzsch@netsystem.de>
Newsgroups gnu.bash.bug
Subject AW: Misbehavior with constants and bash script
Date Tue, 20 Nov 2018 11:38:12 +0000
Lines 41
Approved bug-bash@gnu.org
Message-ID <mailman.4299.1542713903.1284.bug-bash@gnu.org> (permalink)
References <a4ad2b88-48a5-9569-716a-8e22cdb37dde@case.edu>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset="iso-8859-1"
Content-Transfer-Encoding quoted-printable
X-Trace usenet.stanford.edu 1542713904 20052 208.118.235.17 (20 Nov 2018 11:38:24 GMT)
X-Complaints-To action@cs.stanford.edu
To "bug-bash@gnu.org" <bug-bash@gnu.org>
Envelope-to bug-bash@gnu.org
Thread-Topic Misbehavior with constants and bash script
Thread-Index AQHUgEMP54SJp6hR+0aak96ssHT2kaVXsJQAgAAH4ICAAAIugIAAzcuL
In-Reply-To <a4ad2b88-48a5-9569-716a-8e22cdb37dde@case.edu>
Accept-Language de-DE, en-US
Content-Language de-DE
X-MS-Has-Attach
X-MS-TNEF-Correlator
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-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.21
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash/>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:14834

Show key headers only | View raw


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 statements. A variable assignment error occurs, for example, when trying to assign a value to a readonly variable.
[...]"

This helps. So what I need to do to force the script to proceed is to add another command after the assignment statement.

Before ist was

echo "A"
declare -r vconst="I am fixed."
echo "B"
vconst="new value" # fails here
echo "C" # never reached

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 printed

End then it does not matter if bash is in posix mode or not.

Thank you for your help in that matter.

Cheers,
Alex

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


Thread

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

csiph-web