zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: zsh-workers@zsh.org
Subject: Re: [BUG]builtin echo error doing arguments parsing
Date: Thu, 22 Feb 2018 10:32:01 +0000	[thread overview]
Message-ID: <20180222103201.314c839b@pwslap01u.europe.root.pri> (raw)
In-Reply-To: <20180222093711.0777e602@pwslap01u.europe.root.pri>

On Thu, 22 Feb 2018 09:37:11 +0000
Peter Stephenson <p.stephenson@samsung.com> wrote:
> On Wed, 21 Feb 2018 23:23:09 -0800
> wumingxwk@gmail.com wrote:
> > if there is only a '-' as argument,builtin echo won't print it
>
> You might have thought it should at least be turned off in some or most
> of the emulation modes...

Would look something like this.  Probably a good idea if there aren't
subtleties?

pws

diff --git a/Doc/Zsh/builtins.yo b/Doc/Zsh/builtins.yo
index 6c7ec4b..098b989 100644
--- a/Doc/Zsh/builtins.yo
+++ b/Doc/Zsh/builtins.yo
@@ -61,7 +61,9 @@ arguments, but is otherwise ignored.  This is useful in cases where
 arguments to the command may begin with `tt(-)'.  For historical
 reasons, most builtin commands also recognize a single `tt(-)' in a
 separate word for this purpose; note that this is less standard and
-use of `tt(-)tt(-)' is recommended.
+use of `tt(-)tt(-)' is recommended.  Use of a single `tt(-)' to
+terminate option processing is turned off if the option
+tt(POSIX_BUILTINS) is set.
 
 startitem()
 prefix(-)
diff --git a/Doc/Zsh/options.yo b/Doc/Zsh/options.yo
index 25b3d57..5217e62 100644
--- a/Doc/Zsh/options.yo
+++ b/Doc/Zsh/options.yo
@@ -2183,6 +2183,9 @@ Furthermore, the tt(getopts) builtin behaves in a POSIX-compatible
 fashion in that the associated variable tt(OPTIND) is not made
 local to functions.
 
+In addition, a single dash (`tt(-)') does not cause the termination of option
+processing: a double dash (`tt(-)tt(-)') is required.
+
 Moreover, the warning and special exit code from
 tt([[ -o )var(non_existent_option)tt( ]]) are suppressed.
 )
diff --git a/Src/builtin.c b/Src/builtin.c
index fb59738..d2c6ec4 100644
--- a/Src/builtin.c
+++ b/Src/builtin.c
@@ -304,7 +304,8 @@ execbuiltin(LinkList args, LinkList assigns, Builtin bn)
 		if (!(flags & BINF_KEEPNUM) && idigit(arg[1]))
 		    break;
 		/* For cd and friends, a single dash is not an option. */
-		if ((flags & BINF_SKIPDASH) && !arg[1])
+		if (((flags & BINF_SKIPDASH) || isset(POSIXBUILTINS)) &&
+		    !arg[1])
 		    break;
 		if ((flags & BINF_DASHDASHVALID) && !strcmp(arg, "--")) {
 		    /*


  reply	other threads:[~2018-02-22 10:32 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180222072350epcas2p3185ca17f5f0e3ad69b0a41dbf743f145@epcas2p3.samsung.com>
2018-02-22  7:23 ` wumingxwk
2018-02-22  9:37   ` Peter Stephenson
2018-02-22 10:32     ` Peter Stephenson [this message]
2018-02-22 16:50       ` Mikael Magnusson
2018-02-22 17:26         ` Peter Stephenson
2018-02-22 19:00           ` Mikael Magnusson
2018-02-22 19:04             ` Bart Schaefer
2018-02-22 19:34             ` Peter Stephenson
2018-02-24  8:20               ` Stephane Chazelas
2018-02-24  9:51                 ` Peter Stephenson
2018-02-24 19:41                   ` Peter Stephenson
2019-04-27  6:46                 ` 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=20180222103201.314c839b@pwslap01u.europe.root.pri \
    --to=p.stephenson@samsung.com \
    --cc=zsh-workers@zsh.org \
    /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).