Subject: Re: [PATCH] allopt() and question
From: Thilo Six <[email-masked]>
To: [email-masked]
Date: Tue, 10 May 2016 20:55:55 +0200
List-Id: Zsh Workers List <zsh-workers.zsh.org>

Hello

>>> % builtin set -o | command grep -E '(\<monitor\>|\<zle\>)'
>>> monitor off
>>> zle off
>>
>> This will start separate process for the first thing in pipeline. The
>> last thing is run in current shell. Which is cool for me, 
> 
> Now that you mention it i can remeber to have read about that. Back then a bash
> user where this is not the default. But iirc they have nowadays a option for it.
> Still to me this seem not to be the whole story.
> For one it only occurs with only some specific shell options and second:
> 
> % foo="$(builtin set -o)"
> % echo $foo | command grep -E '(\<monitor\>|\<zle\>)'
> monitor               off
> zle                   off
> % allopt '(\<monitor\>|\<zle\>)'
> monitor               on
> zle                   on
> 
> Or am i missing s.th.?

i have been working on making the patch better. During that i noticed
this does work as expected:
    for i in ${OPT_NAMES_ALL} ; do OPT_ALL+=($i ${options[$i]}) ; done

This does not:
    for i in ${OPT_NAMES_ALL} ; do OPT_ALL+=($i ${options[$i]}) ; done | while

So it seems as i allready thought that Zsh is reseting some options when inside
a pipe. Same for 'set -o' and 'setopt' by the way.

Now to the "improvements"-
Meantime i have learned about v and k modifiers which saves a for loop.

The main point i did not like about the previous version was code duplication.
The original version of allopt used a function for that.

There are two reasons why i did went the other approach first:
1)
I often fire up a new instance enter some chars and hit <Tab> just to check if
that command exists already. Mostly in cases where i write new functions to
prevent name clashes.
Function definitions inside functions are hidden from the shell unless the outer
function is run once. So this potentially calls then for name clashes.

2)
One thing i haven't verified yet is, if a local PARAMATER in the outer function
is avail to the inner defined function.
If so that would be nice. If Not that would have reduced code duplication at the
end and doubled it at start of the function where the PARAMETERs are defined.

Actually there is way to have both, or better yet one without the other.
See attached.

All of this is TTBOMK @ $EPOCHSECONDS.

Final: I attach a plain autoload func file. If you are actually interested i
produce a proper patch.

OT:

One last thing i want to say if i am allowed:
When one searches around the web after zsh one of the top most named things is:
what one can put into his PS1.
That i nice actually.
Also modifiers are great.

But if i have to name my top most Zsh killer feature it would be this tiny
little sentence which is easly overlooked:

      One commonly encountered difference is that variables substituted  onto
      the  command line are not split into words.

White-listing of splitting is so much more naturally then black-listing it.

THANK you so much for making a sensible shell!

And now i shut up. ;)

Nice day everyone!

kind regards,

     Thilo