Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14194
| Path | csiph.com!goblin2!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail |
|---|---|
| From | L A Walsh <bash@tlinx.org> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: Conditions with logical operators and nested groups execute "if" and "else" |
| Date | Thu, 31 May 2018 14:22:03 -0700 |
| Lines | 27 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.882.1527801734.1292.bug-bash@gnu.org> (permalink) |
| References | <CAM4RgKgOACdJtjBFpKMhfoXvbSwun=84pPdADNaJVKcd-Z5GFg@mail.gmail.com> <6e150f52-99b9-bea6-9548-2f9910772e42@iki.fi> <5B0F31BF.3050801@tlinx.org> <763ed916-3c32-b883-fe36-405a674c2510@iki.fi> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Trace | usenet.stanford.edu 1527801735 18202 208.118.235.17 (31 May 2018 21:22:15 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| Cc | bug-bash <bug-bash@gnu.org> |
| To | Ilkka Virta <itvirta@iki.fi> |
| Envelope-to | bug-bash@gnu.org |
| User-Agent | Thunderbird |
| In-Reply-To | <763ed916-3c32-b883-fe36-405a674c2510@iki.fi> |
| X-detected-operating-system | by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] [fuzzy] |
| X-Received-From | 173.164.175.65 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.21 |
| 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 | <http://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> |
| Xref | csiph.com gnu.bash.bug:14194 |
Show key headers only | View raw
Ilkka Virta wrote: >> If the 1st expression is false, it would skip directly to >> the '||' and would execute the 3rd clause. >> If the 1st expresion is true then it does the 2nd clause. >> If that is false, the '||' clause is done, but if true, >> the '||' clause would not be done. >> > > In other words, || checks the exit status of the last command that was > executed. > > And as your example shows, 'cmd1 && cmd2 || cmd3' is not the same as > 'if cmd1; then cmd2; else cmd3' which was the comparison this thread > started with. > Yes, you are right. I was confusing exit status with integer status in my example. His code example is further complicated by the fact that cmd2 is never true, and his reduction only is applied once, which doesn't seem right.
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: Conditions with logical operators and nested groups execute "if" and "else" L A Walsh <bash@tlinx.org> - 2018-05-31 14:22 -0700
csiph-web