[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: -e does not take effects in subshell
From: |
Linda Walsh |
Subject: |
Re: -e does not take effects in subshell |
Date: |
Thu, 20 Aug 2015 17:38:00 -0700 |
User-agent: |
Thunderbird |
Chet Ramey wrote:
The earlier spec had -e only exit a script if a *simple* (external)
command failed. It didn't include builtins nor functions.
This is not; builtins and functions are simple commands.
---
The builtins are _complex_ binary blobs that replace external commands.
Functions are a collection of many commands. They are not a single,
simple statement. I remember using their return value in some cases.
With the change, I couldn't run a func and have it return the
value in $? (1 byte, I know) -- but about 128x as flexible
as "ok"/"die" (i.e. any non-zero value triggers the behavior
now, but before, it didn't).
My simplistic view was that -e was there to auto-exit if an external
command failed because they are "out of your control". But if
I write a function -- I design the behavior. Even if I designed in
a bug -- it's still "my code" that has the problem not some
-_e_xternal command
---- cf. perl's option "autodie" -- you can say you want the "open
builtin" to just die on errors, then for simple scripts you don't have
to put extra code to handle each problem. I.e. -- it's not really
something you want in production code, but I write far more throw
away quick and dirty scripts than production ones.
I tried to write a more complex bash script one time -- that met my
expectations. W/o error testing the code was about 150 lines. With
error testing and _helpful_ error messages it was over 1000.
But that's the difference between quick&dirty vs. production.
-e was useful for Q&D, IMO....
- Re: -e does not take effects in subshell, (continued)
- Re: -e does not take effects in subshell, Linda Walsh, 2015/08/18
- Re: -e does not take effects in subshell, Greg Wooledge, 2015/08/18
- Re: -e does not take effects in subshell, Linda Walsh, 2015/08/18
- Re: -e does not take effects in subshell, Andreas Schwab, 2015/08/18
- Re: -e does not take effects in subshell, Linda Walsh, 2015/08/18
- Re: -e does not take effects in subshell, Greg Wooledge, 2015/08/20
- Re: -e does not take effects in subshell, Linda Walsh, 2015/08/20
- Re: -e does not take effects in subshell, Chet Ramey, 2015/08/20
- Re: -e does not take effects in subshell,
Linda Walsh <=
- Re: -e does not take effects in subshell, Chet Ramey, 2015/08/21
- Re: -e does not take effects in subshell, Ángel González, 2015/08/21