Path: csiph.com!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail From: Alexander Reintzsch 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: References: <857e2280-38c5-344e-1916-17a6c6c61b02@netsystem.de>, 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" Envelope-to: bug-bash@gnu.org Thread-Topic: Misbehavior with constants and bash script Thread-Index: AQHUgEMP54SJp6hR+0aak96ssHT2kaVXsJQAgAAH4ICAAAIugIAAzcuL In-Reply-To: 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:14834 Hello Chet,=0A= =0A= thank you for your help and pointing to the posix behavior.=0A= =0A= Quoting =0A= https://www.gnu.org/software/bash/manual/html_node/Bash-POSIX-Mode.html=0A= "[...]=0A= A non-interactive shell exits with an error status if a variable assignment= error occurs when no command name follows the assignment statements. A var= iable assignment error occurs, for example, when trying to assign a value t= o a readonly variable.=0A= [...]"=0A= =0A= This helps. So what I need to do to force the script to proceed is to add a= nother command after the assignment statement.=0A= =0A= Before ist was=0A= =0A= echo "A"=0A= declare -r vconst=3D"I am fixed."=0A= echo "B"=0A= vconst=3D"new value" # fails here=0A= echo "C" # never reached=0A= =0A= and if I add an empty command after the assignment statement it behaves as = expected.=0A= =0A= echo "A"=0A= declare -r vconst=3D"I am fixed."=0A= echo "B"=0A= vconst=3D"new value" : # please note the : at the end. (no operation comman= d)=0A= echo "C" # now printed=0A= =0A= End then it does not matter if bash is in posix mode or not.=0A= =0A= Thank you for your help in that matter.=0A= =0A= Cheers,=0A= Alex=