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


Groups > gnu.bash.bug > #14834 > unrolled thread

AW: Misbehavior with constants and bash script

Started byAlexander Reintzsch <Alexander.Reintzsch@netsystem.de>
First post2018-11-20 11:38 +0000
Last post2018-11-20 11:38 +0000
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

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

#14834 — AW: Misbehavior with constants and bash script

FromAlexander Reintzsch <Alexander.Reintzsch@netsystem.de>
Date2018-11-20 11:38 +0000
SubjectAW: Misbehavior with constants and bash script
Message-ID<mailman.4299.1542713903.1284.bug-bash@gnu.org>
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

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web