[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
readonly changes set -e behavior
From: |
Dennis Kuhn |
Subject: |
readonly changes set -e behavior |
Date: |
Tue, 21 Feb 2017 18:02:42 +0100 |
Hello,
Configuration Information [Automatically generated, do not change]:
Machine: Mac
OS: Darwin
Compiler: gcc
Compilation CFLAGS: Xcode
uname output: Darwin dkuhn 15.6.0 Darwin Kernel Version 15.6.0: Mon Jan 9
23:07:29 PST 2017; root:xnu-3248.60.11.2.1~1/RELEASE_X86_64 x86_64
Machine Type: x86_64-Apple-Darwin
Bash Version: 3.2
Patch Level: 48
Release Status: relase
Description:
Set a variable readonly changes the behavior of "set -e". Here is a small
example:
#!/bin/bash
set -e
s=$(false)
echo "abc"
This script exists with exit code 1 as expected after the subshell line.
When the variable s is set to readonly the script does not exit and echoes
"abc":
#!/bin/bash
set -e
readonly s=$(false)
echo "abc"
This behavior is unexpected. I could reproduce the bug
on ubuntu 16.04 with bash version 4.3-14ubuntu1.1
Regards,
Dennis Kuhn
signature.asc
Description: Message signed with OpenPGP using GPGMail
- readonly changes set -e behavior,
Dennis Kuhn <=