From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2415 invoked by alias); 10 May 2016 18:56:14 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 38465 Received: (qmail 4280 invoked from network); 10 May 2016 18:56:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.1 X-Injected-Via-Gmane: http://gmane.org/ To: zsh-workers@zsh.org From: Thilo Six Subject: Re: [PATCH] allopt() and question Date: Tue, 10 May 2016 20:55:55 +0200 Message-ID: References: <572C697B.9010607@xk2c.de> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------010300010002010302000306" X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: p5de5bc07.dip0.t-ipconnect.de In-Reply-To: <572C697B.9010607@xk2c.de> --------------010300010002010302000306 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Hello >>> % builtin set -o | command grep -E '(\|\)' >>> 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 off > zle off > % allopt '(\|\)' > 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 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 --------------010300010002010302000306 Content-Type: text/plain; charset=UTF-8; name="allopt" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="allopt" IyB2aW06IHRzPTg6c3c9NDpzdHM9NDpldDpmdD16c2g6CiMga2F0ZTogYnl0ZS1vcmRlci1t YXJrZXIgZmFsc2U7IGR5bmFtaWMtd29yZC13cmFwIGZhbHNlOyBpbmRlbnQtbW9kZSBub3Jt YWw7IGluZGVudC1wYXN0ZWQtdGV4dCB0cnVlOyBpbmRlbnQtd2lkdGggNDsga2VlcC1leHRy YS1zcGFjZXMgZmFsc2U7IG5ld2xpbmUtYXQtZW9mIHRydWU7IHJlbW92ZS10cmFpbGluZy1z cGFjZXMgYWxsOyByZXBsYWNlLXRhYnMgdHJ1ZTsgcmVwbGFjZS10YWJzLXNhdmUgdHJ1ZTsg c2hvdy10YWJzIHRydWU7IHNtYXJ0LWhvbWUgdHJ1ZTsgc3ludGF4IFpzaDsgdGFiLXdpZHRo IDg7IHdvcmQtd3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319CiAgICAgICAgZWxzZQogICAgICAgICAgICBjYXQK ICAgICAgICBmaQogICAgfQojIH0KCg== --------------010300010002010302000306--