From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: zsh-workers-return-43694-ml=inbox.vuxu.org@zsh.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 4b710f15 for ; Tue, 16 Oct 2018 09:42:32 +0000 (UTC) Received: (qmail 22567 invoked by alias); 16 Oct 2018 09:42:21 -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: List-Unsubscribe: X-Seq: 43694 Received: (qmail 25172 invoked by uid 1010); 16 Oct 2018 09:42:21 -0000 X-Qmail-Scanner-Diagnostics: from mailout2.w1.samsung.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(210.118.77.12):SA:0(-7.0/5.0):. Processed in 23.367072 secs); 16 Oct 2018 09:42:21 -0000 X-Envelope-From: p.stephenson@samsung.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20181016093354euoutp029a3c0d21838a6e6d90972910c05b0848~eDQQzFLiG2441524415euoutp02m DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1539682434; bh=z5Lkf/nV8Gsmk6v7BV3RXvedhEtFoqJcboG/kKl6Uto=; h=Subject:From:To:Date:In-Reply-To:References:From; b=Ua4P2uCCqcYL45qq+ahYAc1CxUbvm8TFDE0OS9Y5gK9lmxtFOxVhlbXHYzYwO7H5B 1x01ZoLcmBoItcHDUgUKyxymQvnrRwIq+X8C14lm+eqglLXZmbl9WVaKPCfbx0s4iA 31ShC99KIVsvsZ9VAlBfC57rF7WKR6i6BwWLjZ1M= X-AuditID: cbfec7f4-835ff700000010c6-13-5bc5b0817795 Subject: Re: Documentation about Multios is misleading, and perhaps untrue From: Peter Stephenson To: Date: Tue, 16 Oct 2018 10:33:51 +0100 In-Reply-To: <1539655655.1396893.1543274624.1FAEEE73@webmail.messagingengine.com> X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHIsWRmVeSWpSXmKPExsWy7djPc7qNG45GG3z5KWxxsPkhkwOjx6qD H5gCGKO4bFJSczLLUov07RK4MqZP/8Vc0KFUcbdnPksD41XpLkZODgkBE4ntaxcwdzFycQgJ rGCUuHrxMxuE08ck8WL+bhYIp5dJYuqUFewwLY2PT0G1LGeU+H//IkLVvnOvmCCcM4wSd15f YwJpERK4wCix9wjYRmEBL4l/y16zgdhsAoYSUzfNZgSxRQQkJa41nwazWQRUJe79mQy2jlMg UGLytXusEKs1JDbcPAY2k1dAUOLkzCcsIDazgLxE89bZYCdJCDxmk/g++RoLRFGZxIpl86Hu dpHom/AdapCwxKvjW6DiMhKnJ/ewQDS3M0qsmfSaHcLpYZTYdPQOI0SVtUTf7YtANgfQOk2J 9bv0QUwJAUeJP9fqIEw+iRtvBSHu4ZOYtG06M0SYV6KjTQhihprEjqatjBBhGYmnaxQmMCrN QvLMLCTPzELYtICReRWjeGppcW56arFRXmq5XnFibnFpXrpecn7uJkZgKjj97/iXHYy7/iQd YhTgYFTi4f1x/Ui0EGtiWXFl7iFGCQ5mJRFe2cqj0UK8KYmVValF+fFFpTmpxYcYpTlYlMR5 l83bGC0kkJ5YkpqdmlqQWgSTZeLglGpgZEysM1/HuGHPmUjZ1TpLs79P3/5f9h2D+e2c0s8X vOxkswL+2fyxfSt96NI8lkfZultWHl8hfvDln9e/X3KVn/oou8ymYB9Dg8XbdVWfWMKLns5l Fsz5dC3g95nczY/OcytOvvryN69CrHPNZ4+3f2MPKW3fwXzhllGywp1ZZzLel2rsPzGbzUmJ pTgj0VCLuag4EQC5qaNkAQMAAA== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpmkeLIzCtJLcpLzFFi42I5/e/4Xd2GDUejDW7PELY42PyQyYHRY9XB D0wBjFF6NkX5pSWpChn5xSW2StGGFkZ6hpYWekYmlnqGxuaxVkamSvp2NimpOZllqUX6dgl6 GdOn/2Iu6FCquNszn6WB8ap0FyMnh4SAiUTj41PMXYxcHEICSxklTjUdZIVIyEh8uvKRHcIW lvhzrYsNoqibSeLan2uMEM4ZRokTrZNZIJwLjBJty7+AtfMKGEp8nf2DEcQWFvCS+LfsNRuI zQYUn7ppNlhcREBS4lrzaTCbRUBV4t6fyWDrOAUCJSZfu8cKMXQtq8SD9jVgzcwCmhKt239D 3aQhseHmMSaIZYISJ2c+YYGokZdo3jqbeQKj0CwkLbOQlM1CUraAkXkVo0hqaXFuem6xkV5x Ym5xaV66XnJ+7iZGYARsO/Zzyw7GrnfBhxgFOBiVeHh/XD8SLcSaWFZcmXuIUYKDWUmEV7by aLQQb0piZVVqUX58UWlOavEhRlOgjyYyS4km5wOjM68k3tDU0NzC0tDc2NzYzEJJnPe8QWWU kEB6YklqdmpqQWoRTB8TB6dUA6NF1yOHGxO6TttMfDdbo+Opd3PDNVer+lP3p+06HuT46Jd7 4PW5b34YavFWKO0XvLbx5gLFnXw+Gx1WFeVWvbgpcm87y7E3XH9jwn8mc3sef7Z/6w+lfoOX JxZKTzgZksZjM+3KjcTXyWuLrqnxZt1d19qY1jT7gcuiaWe9N1S2vmScw3Eqcm2BEktxRqKh FnNRcSIAPxEK0JYCAAA= Message-Id: <20181016093352eucas1p1eb6d365dbaffbf96150c3d4eaf345c63~eDQPNnGXe0479104791eucas1p1L@eucas1p1.samsung.com> X-CMS-MailID: 20181016093352eucas1p1eb6d365dbaffbf96150c3d4eaf345c63 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20181011210006epcas4p459f3f70e15e1a0c0ac11a64967651f3c X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20181011210006epcas4p459f3f70e15e1a0c0ac11a64967651f3c References: <8B27B616-9DDE-4A04-AA05-2EA7234051A0@dana.is> <1539290119.4188692.1539037288.272C51E2@webmail.messagingengine.com> <20181012083056eucas1p1254a57c82328a4e9349c3a6f8997a0e6~cz0JMnlc50925009250eucas1p10@eucas1p1.samsung.com> <1539655655.1396893.1543274624.1FAEEE73@webmail.messagingengine.com> On Tue, 2018-10-16 at 02:07 +0000, Daniel Shahaf wrote: > However, I agree with your overall point, that the statement about > "equivalence" in the manual is incorrect.  At the same time, I think a > different fix would be better: >  > 1. Ensure that it's documented that all redirections (input and output) >    are opened before the command is even exec'd.  This is true for all >    redirections, not just for MULTIOS syntaxes. >  > 2. In the section that gives analogies to cat(1) and sort(1), simply >    state that the examples assume that all dirent names are ordinary, >    readable files. >  > Makes sense?  Anybody volunteering to write the patch (not me)? Not really.  This is the same point as Bart's --- that this is documentation for zsh, not a primer on how shells work. I won't labour the point, but this isn't a good place to document how a shell normally does redirection. Where I think there is a point here is for multios, where there is an extra process hidden away to concatenate the files (and it's a forked shell, not a "cat").  The fact that *that* process opens files immediately isn't obvious and isn't standard.  So this could probably do with a comment somewhere.  I've added this below (this updates my previous comparison with cat). Qualifying the documentation to say if this isn't an ordinary file or isn't readable it might not behave in an ordinary way or you might not be able to read it is also verbiage that's trying to cover for ignorance beyond what the shell manual can deal with.  We could just as well document any example in the manual that uses files to say you need to be able to read them or you'll get an error, or that if it's a special file it might be special.  Our job is instead to document, for example, the way the nature of an error might differ from what a shell user might expect. One of our big problems is people finding the existing documentation too thick to get through.  We can go on making it wordier and harder to get through till the cows come home and it still won't make it a basic shell primer. What's needed here is not zsh documentation, it's something properly written in its own right that introduces what a redirection (and, indeed, everything else) is.  This would give proper examples and context and comparisons and further reading and stuff you just don't get in user manuals for tools, any tool.  Such things no doubt exist and it would be better to refer to here rather than do a half-baked job ourselves. I have to say, even there, that if you look at my user guide (now rather old, but basic syntax hasn't changed): http://zsh.sourceforge.net/Guide/zshguide03.html#l60 which is very much more verbose, I think I assume even there that it's obvious that in general (and ignoring the special nature of multios) a redirection happens before the command is run.  But that's the sort of place to mention this sort of thing. pws diff --git a/Doc/Zsh/redirect.yo b/Doc/Zsh/redirect.yo index c793638..2c406b6 100644 --- a/Doc/Zsh/redirect.yo +++ b/Doc/Zsh/redirect.yo @@ -234,6 +234,9 @@ example(date >foo | cat)    writes the date to the file `tt(foo)', and also pipes it to cat.   +Note that the shell opens all the files to be used in the multio process +immediately, not at the point they are about to be written. +  Note also that redirections are always expanded in order.  This happens  regardless of the setting of the tt(MULTIOS) option, but with the option  in effect there are additional consequences. For example, @@ -268,9 +271,13 @@ example(echo exit 0 >> *.sh)    If the user tries to open a file descriptor for reading more than once,  the shell opens the file descriptor as a pipe to a process that copies -all the specified inputs to its output in the order -specified, similar to bf(cat), -provided the tt(MULTIOS) option is set.  Thus +all the specified inputs to its output in the order specified, provided +the tt(MULTIOS) option is set.  It should be noted that each file is +opened immediately, not at the point where it is about to be read: +this behaviour differs from tt(cat), so if strictly standard behaviour +is needed, tt(cat) should be used instead. + +Thus    example(sort