Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14194
| 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 | 2018-05-31 14:22 -0700 |
| 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> |
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