zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <Stephane_Chazelas@yahoo.fr>
To: Peter Stephenson <pws@csr.com>,
	Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: [PATCH] Re: f() { ...; } > file
Date: Thu, 13 Nov 2008 15:13:28 +0000	[thread overview]
Message-ID: <20081113151328.GE5114@sc.homeunix.net> (raw)
In-Reply-To: <20081113150335.GD5114@sc.homeunix.net>

On Thu, Nov 13, 2008 at 03:03:35PM +0000, Stephane Chazelas wrote:
[...]
> Note that POSIX has specified it with a restriction in that you
> can only stick "foo()" in front of complex command, and bash is
> the only shell to enforce that restriction.
[...]

Sorry the proper term is "compound command". Here is the text
from SUSv3:

SUS>   The format of a function definition command is as
SUS>   follows:
SUS> 
SUS> fname() compound-command[io-redirect ...]
SUS> 
[...]
SUS>   The argument compound-command represents a compound
SUS>   command, as described in Compound Commands.
SUS> 
SUS>   When the function is declared, none of the expansions in
SUS>   Word Expansions shall be performed on the text in
SUS>   compound-command or io-redirect; all expansions shall be
SUS>   performed as normal each time the function is called.
SUS>   Similarly, the optional io-redirect redirections and any
SUS>   variable assignments within compound-command shall be
SUS>   performed during the execution of the function itself,
SUS>   not the function definition. See Consequences of Shell
SUS>   Errors for the consequences of failures of these
SUS>   operations on interactive and non-interactive shells.
[...]
SUS>   The compound-command shall be executed whenever the
SUS>   function name is specified as the name of a simple
SUS>   command (see Command Search and Execution). The operands
SUS>   to the command temporarily shall become the positional
SUS>   parameters during the execution of the compound-command;
SUS>   the special parameter '#' also shall be changed to
SUS>   reflect the number of operands. The special parameter 0
SUS>   shall be unchanged. When the function completes, the
SUS>   values of the positional parameters and the special
SUS>   parameter '#' shall be restored to the values they had
SUS>   before the function was executed. If the special built-in
SUS>   return is executed in the compound-command, the function
SUS>   completes and execution shall resume with the next
SUS>   command after the function call.

So, at the moment, zsh is not conformant. The patch I suggested
seems to fix it but introduces some display glitches.

-- 
Stéphane


  reply	other threads:[~2008-11-13 15:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-05 21:20 Stephane Chazelas
2008-11-05 22:49 ` Phil Pennock
2008-11-06 14:38   ` Stephane Chazelas
2008-11-13 14:25 ` Stephane Chazelas
2008-11-13 14:42 ` [PATCH] " Stephane Chazelas
2008-11-13 14:52   ` Peter Stephenson
2008-11-13 15:03     ` Stephane Chazelas
2008-11-13 15:13       ` Stephane Chazelas [this message]
2008-11-13 15:27         ` Peter Stephenson
2008-11-13 14:55   ` Stephane Chazelas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081113151328.GE5114@sc.homeunix.net \
    --to=stephane_chazelas@yahoo.fr \
    --cc=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).