Re: Bash true/false builtings undocumented? "false" not working?

2018-08-23 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Thu, Aug 23, 2018 at 02:59:18PM +0200, Stefan Krusche wrote: [...] > Nothing. What Tomás wrote is false (has exit code "1" ;-) > > This: > > test $? && echo ok || echo error $? > > does *not* expand as Tomás said to: > > test 0 && echo ok

Re: Bash true/false builtings undocumented? "false" not working?

2018-08-23 Thread Stefan Krusche
Am Freitag 17 August 2018 schrieb Zenaan Harkness: > On Fri, Aug 17, 2018 at 11:25:52AM +0200, to...@tuxteam.de wrote: > > On Fri, Aug 17, 2018 at 06:46:54PM +1000, Zenaan Harkness wrote: > > > 1) > > > Bash man page largely fails to document the true and false builtins > > > AFAICT, except for

Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread Zenaan Harkness
On Fri, Aug 17, 2018 at 08:23:51AM -0400, Greg Wooledge wrote: > Simply use "if" like you're supposed to. Sometimes the simple things in bash are free. Or something :) Thank you so much Greg - I really appreciate this - this was the answer I didn't know I wanted until you named it. Kind

Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread Zenaan Harkness
On Fri, Aug 17, 2018 at 04:36:43PM +0200, to...@tuxteam.de wrote: > On Fri, Aug 17, 2018 at 10:12:54AM -0400, Greg Wooledge wrote: > > On Fri, Aug 17, 2018 at 03:43:58PM +0200, to...@tuxteam.de wrote: > > > The construction > > > > > > foo && echo "bar" || echo "baz" > > > > > > does probably

Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Fri, Aug 17, 2018 at 10:12:54AM -0400, Greg Wooledge wrote: > On Fri, Aug 17, 2018 at 03:43:58PM +0200, to...@tuxteam.de wrote: > > The construction > > > > foo && echo "bar" || echo "baz" > > > > does probably work, because echo's exit status

Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread Greg Wooledge
On Fri, Aug 17, 2018 at 03:43:58PM +0200, to...@tuxteam.de wrote: > The construction > > foo && echo "bar" || echo "baz" > > does probably work, because echo's exit status is (always?) 0 (the bash > builtin's documentation mumbles something about "write error"). echo can fail if stdout is

Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Fri, Aug 17, 2018 at 08:23:51AM -0400, Greg Wooledge wrote: > On Fri, Aug 17, 2018 at 06:46:54PM +1000, Zenaan Harkness wrote: > > $ test $? && echo ok || echo error $? > > Others have already pointed out that test $? is not what you think it >

Re: Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Fri, Aug 17, 2018 at 12:34:38PM +0100, Clive Standbridge wrote: [...] > > $ 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,

Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread Greg Wooledge
On Fri, Aug 17, 2018 at 06:46:54PM +1000, Zenaan Harkness wrote: > $ test $? && echo ok || echo error $? Others have already pointed out that test $? is not what you think it is. When the test command is given 1 argument, it tests that argument's string length. If the string length is 0, then

Re: Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread Clive Standbridge
> 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

Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Fri, Aug 17, 2018 at 07:29:47PM +1000, Zenaan Harkness wrote: > On Fri, Aug 17, 2018 at 10:51:03AM +0200, Nicolas George wrote: > > Zenaan Harkness (2018-08-17): > > > But whilst the subsequent list of Bash builtin commands DOES include > > >

Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Fri, Aug 17, 2018 at 11:42:56AM +0200, to...@tuxteam.de wrote: [...] > Few surviving languages have that kind of evaluation model (the shells, > Tcl -- and in a very interesting twist the Lisps). Powerful, but > sometimes confusing. And (oh,

Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Fri, Aug 17, 2018 at 07:32:39PM +1000, Zenaan Harkness wrote: [...] > That accords with my previous understanding, that the exist status of > running false gives something other than "success" (i.e. zero) - what > am I missing? The next step:

Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread Nicolas George
Zenaan Harkness (2018-08-17): > Aha. It's actually the Special Parameter "?", aka "$?" that I did not > understand - I was treating it as a value, when actually it is > something that expands, i.e. into a string, and not something that is > treated as true or false. That is how all parameters

Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread Zenaan Harkness
On Fri, Aug 17, 2018 at 11:25:52AM +0200, to...@tuxteam.de wrote: > On Fri, Aug 17, 2018 at 06:46:54PM +1000, Zenaan Harkness wrote: > > 1) > > Bash man page largely fails to document the true and false builtins > > AFAICT, except for this sentence just under the heading > > "^SHELL BUILTIN

Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread Zenaan Harkness
On Fri, Aug 17, 2018 at 10:51:03AM +0200, Nicolas George wrote: > Zenaan Harkness (2018-08-17): > > But whilst the subsequent list of Bash builtin commands DOES include > > entries for ":" (the very first entry) and "test", it appears to fail > > to include entries for "true" and for "false". > >

Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread tomas
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On Fri, Aug 17, 2018 at 06:46:54PM +1000, Zenaan Harkness wrote: > 1) > Bash man page largely fails to document the true and false builtins > AFAICT, except for this sentence just under the heading > "^SHELL BUILTIN COMMANDS": > > The :, true,

Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread Zenaan Harkness
On Fri, Aug 17, 2018 at 10:51:03AM +0200, Nicolas George wrote: > Zenaan Harkness (2018-08-17): > > But whilst the subsequent list of Bash builtin commands DOES include > > entries for ":" (the very first entry) and "test", it appears to fail > > to include entries for "true" and for "false". > >

Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread Nicolas George
Zenaan Harkness (2018-08-17): > But whilst the subsequent list of Bash builtin commands DOES include > entries for ":" (the very first entry) and "test", it appears to fail > to include entries for "true" and for "false". Maybe because it does the same thing as the standard and non-builtin true

Re: Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread Zenaan Harkness
On Fri, Aug 17, 2018 at 06:46:54PM +1000, Zenaan Harkness wrote: > 1) > Bash man page largely fails to document the true and false builtins > AFAICT, except for this sentence just under the heading > "^SHELL BUILTIN COMMANDS": > > The :, true, false, and test builtins do not accept options and

Bash true/false builtings undocumented? "false" not working?

2018-08-17 Thread Zenaan Harkness
1) Bash man page largely fails to document the true and false builtins AFAICT, except for this sentence just under the heading "^SHELL BUILTIN COMMANDS": The :, true, false, and test builtins do not accept options and do not treat -- specially. But whilst the subsequent list of Bash builtin