Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #15471
| Path | csiph.com!3.us.feeder.erje.net!feeder.erje.net!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail |
|---|---|
| From | John W <jwdevel@gmail.com> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: Bug? `set -e` inside functions inside `$(...)` |
| Date | Thu, 3 Oct 2019 17:58:02 -0700 |
| Lines | 57 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.934.1570163406.2651.bug-bash@gnu.org> (permalink) |
| References | <CADO30sqtGh+O54c0pLic-8YA00VG244gcRY8x8XFv8yHNby5yA@mail.gmail.com> <CADO30spotrQHiTWfKFngTPERSypRz3PgJRh+UA1EKv_D=qGiBQ@mail.gmail.com> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="UTF-8" |
| X-Trace | usenet.stanford.edu 1570163407 29211 209.51.188.17 (4 Oct 2019 04:30:07 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| To | bug-bash@gnu.org |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=QUYp0OPnFTLfjcGJbP7xKO/RjngJqVSLP1GUooT8vhk=; b=lxERGgpu+EH8S4LiSrziHIkXuX7S0Q3j28R+u0TbCkoPKmpAj1JudIdDOBje4DOWSk wIa8Z8BDLUV8PO4RBNt2faau892INfuIdAmRZVSPhT9CsxlZ0NAZLkLU7+XgDU7BYgVQ h5KWZh5K4jS7D2e66FjToA4M+5P0wQjfRsTPAzi9q8UttUTZWVfLj4q8ARjWUyISOoTS bxOooJDvFW21mQ4UaQLNcT5JNG2WQPOUG2/lSV0oY2TVMkDlKkD/yRJFM4Xn+oqtxh+v b6OLzA7hYGNI9u1K0MzMMS5w97F50rxhhdM7GHthe5z3n9Pq4xFo6IfnM3eZFr6JCrZ3 fHfQ== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=QUYp0OPnFTLfjcGJbP7xKO/RjngJqVSLP1GUooT8vhk=; b=XnEP2xDzM7RG4KAPptvYoHVhgSePA1DkBOxmHZGDazgKhjDj+uQahvFwYSY1pPf1tO 909gI/ZCEQKnPIXwvz2O1AgfNGWAyEJX4+rRT66H2Xy38HSBY1vnJ1MDeCc9jpNiE8E8 omiNKtYGMmFCiZQthemNjLsOg6ytdOrQ5e3/1mCByX8ZEDHhtdKnSL0oRC4OcRaYwV+0 bW9YDnqQMLaNRZzblayd3RQjS4IO4cFElpGbwAy49OpPizdmzQC8Y5GLzR31WtISgTTM kqJ8WOP0RwSyiJNt6qDElgUHiguf93if6OntPhgdy1IDetYeigRL0jWz9JVMjSWbVkk7 ltTg== |
| X-Gm-Message-State | APjAAAUynDMScqlacCmPZTMMmQi9cyZSZ/GzPXjtMRqFpLTj6eIhqzqw JS8i0My0oR0PB33Mr89luHdxy/SOBH/+m83fYyDh0Q== |
| X-Google-Smtp-Source | APXvYqx3Nw3cLg311KCaChZW1QsBoL4VO6uBpWhhz7UCedAArrDTOdBsxF3UAFrXrCFiBvDI90xOJ1pg5f28UqauMuo= |
| X-Received | by 2002:adf:fe05:: with SMTP id n5mr864537wrr.355.1570150683158; Thu, 03 Oct 2019 17:58:03 -0700 (PDT) |
| In-Reply-To | <CADO30sqtGh+O54c0pLic-8YA00VG244gcRY8x8XFv8yHNby5yA@mail.gmail.com> |
| X-detected-operating-system | by eggs.gnu.org: Genre and OS details not recognized. |
| X-Received-From | 2a00:1450:4864:20::42f |
| X-Mailman-Approved-At | Fri, 04 Oct 2019 00:30:04 -0400 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.23 |
| 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 | <https://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> |
| X-Mailman-Original-Message-ID | <CADO30spotrQHiTWfKFngTPERSypRz3PgJRh+UA1EKv_D=qGiBQ@mail.gmail.com> |
| X-Mailman-Original-References | <CADO30sqtGh+O54c0pLic-8YA00VG244gcRY8x8XFv8yHNby5yA@mail.gmail.com> |
| Xref | csiph.com gnu.bash.bug:15471 |
Show key headers only | View raw
Ah, got it sorted out.
Not a bug, of course (:
Bash, when not in posix mode, clears the '-e' flag in subshell environments.
On 10/3/19, John W <jwdevel@gmail.com> wrote:
> I'm seeing some strange behavior w/regard to `set -e` when invoking a
> shell function through a `$(...)` construct.
>
> I can't tell if it's a bug or not; the manpage doesn't really mention
> $() specially with regard to `set -e`, that I have found.
>
> I made a SO post with a bunch of details here:
> https://stackoverflow.com/questions/58228383/bash-set-e-reset-inside-functions-when-run-via
>
> But here's my small repro program:
>
> #!/usr/bin/env bash
>
> echo "Initial: $-"
> set -eu
> echo "After set: $-"
>
> function foo() {
> echo "Inside foo: $-"
> }
> foo
>
> function bar() {
> false # I'd expect this to immediately fail
> echo "Inside bar: $-"
> }
> # When a $(...) construct is involved, 'bar' runs to completion!
> x=$(bar)
> echo "We should never get here ... but we do."
> echo "$x"
>
> For me, this ouputs:
>
> Initial: hB
> After set: ehuB
> Inside foo: ehuB
> We should never get here ... but we do.
> Inside bar: huB
>
> and it's really the last two lines that confuse me. Why was 'set -e'
> disabled inside of "bar"?
>
> Is this documented behavior, and I missed it?
> Or a bug?
> Or makes sense under some interpretation of things that I'm not grasping?
>
> Thanks for any advice
> -John
>
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: Bug? `set -e` inside functions inside `$(...)` John W <jwdevel@gmail.com> - 2019-10-03 17:58 -0700
csiph-web