Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.debian.user > #198928
| From | Clive Standbridge <list-user@tgstandbridges.plus.com> |
|---|---|
| Newsgroups | linux.debian.user |
| Subject | Re: Re: Bash true/false builtings undocumented? "false" not working? |
| Date | 2018-08-17 14:10 +0200 |
| Message-ID | <wnLJM-8lc-7@gated-at.bofh.it> (permalink) |
| References | <wnJoB-6ND-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
> Is there a "cleaner" way to test the true/ error exit status other > than using "$?", with bonus points for working in posix sh as well as > Bash, ? test $? -eq 0 "help test" will tell you more. Another point from your original mail, > $ false > $ test $? && echo ok || echo error $? The second $? in that line is different from the first; it's the exit status of "test". That can be demonstrated, with a corrected test command, by $ grep stuff /no/such/file grep: /no/such/file: No such file or directory $ echo $? 2 $ grep stuff /no/such/file grep: /no/such/file: No such file or directory $ test $? -eq 0 && echo ok || echo error $? error 1 As was mentioned in an earlier reply, you can get round that by saving the exit status in a variable, e.g. $ grep stuff /no/such/file grep: /no/such/file: No such file or directory $ RET=$? $ test $RET -eq 0 && echo ok || echo error $RET error 2 -- Cheers, Clive
Back to linux.debian.user | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Bash true/false builtings undocumented? "false" not working? Zenaan Harkness <zenaan@freedbms.net> - 2018-08-17 10:50 +0200
Re: Bash true/false builtings undocumented? "false" not working? Zenaan Harkness <zenaan@freedbms.net> - 2018-08-17 11:00 +0200
Re: Bash true/false builtings undocumented? "false" not working? Nicolas George <george@nsup.org> - 2018-08-17 11:00 +0200
Re: Bash true/false builtings undocumented? "false" not working? Zenaan Harkness <zenaan@freedbms.net> - 2018-08-17 11:30 +0200
Re: Bash true/false builtings undocumented? "false" not working? Zenaan Harkness <zenaan@freedbms.net> - 2018-08-17 11:40 +0200
Re: Bash true/false builtings undocumented? "false" not working? Nicolas George <george@nsup.org> - 2018-08-17 11:40 +0200
Re: Bash true/false builtings undocumented? "false" not working? <tomas@tuxteam.de> - 2018-08-17 12:20 +0200
Re: Re: Bash true/false builtings undocumented? "false" not working? Clive Standbridge <list-user@tgstandbridges.plus.com> - 2018-08-17 14:10 +0200
Re: Re: Bash true/false builtings undocumented? "false" not working? <tomas@tuxteam.de> - 2018-08-17 15:40 +0200
Re: Bash true/false builtings undocumented? "false" not working? Greg Wooledge <wooledg@eeg.ccf.org> - 2018-08-17 14:30 +0200
Re: Bash true/false builtings undocumented? "false" not working? <tomas@tuxteam.de> - 2018-08-17 15:50 +0200
Re: Bash true/false builtings undocumented? "false" not working? Greg Wooledge <wooledg@eeg.ccf.org> - 2018-08-17 16:20 +0200
Re: Bash true/false builtings undocumented? "false" not working? <tomas@tuxteam.de> - 2018-08-17 16:40 +0200
Re: Bash true/false builtings undocumented? "false" not working? Zenaan Harkness <zenaan@freedbms.net> - 2018-08-18 01:10 +0200
Re: Bash true/false builtings undocumented? "false" not working? Zenaan Harkness <zenaan@freedbms.net> - 2018-08-18 01:30 +0200
Re: Bash true/false builtings undocumented? "false" not working? <tomas@tuxteam.de> - 2018-08-17 11:30 +0200
Re: Bash true/false builtings undocumented? "false" not working? Zenaan Harkness <zenaan@freedbms.net> - 2018-08-17 11:40 +0200
Re: Bash true/false builtings undocumented? "false" not working? <tomas@tuxteam.de> - 2018-08-17 11:50 +0200
Re: Bash true/false builtings undocumented? "false" not working? tomas@tuxteam.de - 2018-08-17 12:00 +0200
Re: Bash true/false builtings undocumented? "false" not working? Stefan Krusche <linux@stefan-krusche.de> - 2018-08-23 15:00 +0200
Re: Bash true/false builtings undocumented? "false" not working? <tomas@tuxteam.de> - 2018-08-23 16:30 +0200
csiph-web