Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [BUG] multibyte never set according to setopt/unsetopt output



On Fri, Jan 19, 2024 at 7:02 AM Mark J. Reed <markjreed@xxxxxxxxx> wrote:
>
> Basically, because `multibyte` is on by default, the *`setopt` commands behave as if there were instead an option with the inverted meaning named `nomultibyte`, and it is that string rather than `multibyte` which shows up

History lesson time for the interested (and who haven't been here all along) ...

Originally most of zsh's options (dozens have been added since) were
based on BSD csh options.  In csh, the defaults were always on, and if
you wanted something to not happen, you had to assert a negative.
Hence for example issuing a "no match" error on a failed glob is
default behavior, and to disable that you assert "nonomatch".
Consequently zsh had "setopt nonomatch" and a number of other options
with a "no" prefix that meant to turn some behavior off.  This led to
a lot of double-negatives when trying to toggle an option via the
"unsetopt" command.

Zsh's first innovation to try to account for this was to start looking
for that leading "no" and reversing the meaning for setopt/unsetopt
based on its presence or absence -- but internally the options were
still named, and therefore documented, in the original forms.

Later (but before the code moved into CVS and thence git, so AFAIK
it's not findable in the commit logs) there was an effort made to
force as many options as possible to be coded and documented in the
"positive" sense, to remove the double negatives internally and make
it possible to do so in scripts -- but the operation of the setopt and
unsetopt commands with respect to a leading "no" was kept unchanged
for backward compatibility, and their respective output still follows
that convention.

Consequently most of the time when a function is asserting a
particular option state, you'll see a single "setopt localoptions"
followed by a mix of options with or without a "no" prefix, because
that's more concise than writing setopt to turn things on and
following that with unsetopt to turn other things off, even though the
option names are now arranged so as to permit exactly that.




Messages sorted by: Reverse Date, Date, Thread, Author