zsh-users
 help / color / mirror / code / Atom feed
* Default true boolean zstyle
@ 2016-10-14  6:27 Sebastian Gniazdowski
  2016-10-14 17:53 ` Bart Schaefer
       [not found] ` <CAH+w=7Za9OrnssbzWN88F2RHoFdVhNKy0_k93P=ZQXQcjY2RZg__38913.3170749576$1476473552$gmane$org@mail.gmail.com>
  0 siblings, 2 replies; 3+ messages in thread
From: Sebastian Gniazdowski @ 2016-10-14  6:27 UTC (permalink / raw)
  To: Zsh Users

Hello,
following code explains:

% zstyle -b ":test-context" test_var test_var || test_var="yes"
% echo $test_var
yes
% zstyle ":test-context" test_var 0
% zstyle -b ":test-context" test_var test_var || test_var="yes"
% echo $test_var
yes

Apparently, zstyle -b returns false when the boolean being read is
false. So "|| test_var=yes" is triggered, and the value is
overwritten. Following way also doesn't do what's expected:

% test_var="yes"
% zstyle -b ":test-context" test_var test_var
% echo $test_var
no

Is there a way to have default-true boolean with zstyle?

Best regards,
Sebastian Gniazdowski


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Default true boolean zstyle
  2016-10-14  6:27 Default true boolean zstyle Sebastian Gniazdowski
@ 2016-10-14 17:53 ` Bart Schaefer
       [not found] ` <CAH+w=7Za9OrnssbzWN88F2RHoFdVhNKy0_k93P=ZQXQcjY2RZg__38913.3170749576$1476473552$gmane$org@mail.gmail.com>
  1 sibling, 0 replies; 3+ messages in thread
From: Bart Schaefer @ 2016-10-14 17:53 UTC (permalink / raw)
  To: Zsh Users

On Thu, Oct 13, 2016 at 11:27 PM, Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
>
> Apparently, zstyle -b returns false when the boolean being read is
> false.
>
> Is there a way to have default-true boolean with zstyle?

You have to use
    zstyle -T :test-context test-style && test_var=yes || zstyle -b
:test-context test-style test_var


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Default true boolean zstyle
       [not found] ` <CAH+w=7Za9OrnssbzWN88F2RHoFdVhNKy0_k93P=ZQXQcjY2RZg__38913.3170749576$1476473552$gmane$org@mail.gmail.com>
@ 2016-10-14 20:12   ` Daniel Shahaf
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Shahaf @ 2016-10-14 20:12 UTC (permalink / raw)
  To: Zsh Users

Bart Schaefer wrote on Fri, Oct 14, 2016 at 10:53:01 -0700:
> On Thu, Oct 13, 2016 at 11:27 PM, Sebastian Gniazdowski
> <sgniazdowski@gmail.com> wrote:
> >
> > Apparently, zstyle -b returns false when the boolean being read is
> > false.
> >
> > Is there a way to have default-true boolean with zstyle?
> 
> You have to use
>     zstyle -T :test-context test-style && test_var=yes || zstyle -b
> :test-context test-style test_var

It's still surprising (and undocumented) that -b returns false when the
value of the style is false.  I expected it to return 0 for the same
reason that _call_function returns 0 when the called function returns
non-zero: $? == 0 means retrieving the value succeeded; check $test_var
to see what the value is.

But it's been this way for 15+ years...


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-14 20:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-14  6:27 Default true boolean zstyle Sebastian Gniazdowski
2016-10-14 17:53 ` Bart Schaefer
     [not found] ` <CAH+w=7Za9OrnssbzWN88F2RHoFdVhNKy0_k93P=ZQXQcjY2RZg__38913.3170749576$1476473552$gmane$org@mail.gmail.com>
2016-10-14 20:12   ` Daniel Shahaf

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).