zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: Zsh hackers list <zsh-workers@sunsite.dk>
Subject: Re: "." not recognising "--" as the end-of-options
Date: Tue, 28 Oct 2008 21:49:52 +0000	[thread overview]
Message-ID: <20081028214952.3bd0b64f@pws-pc> (raw)
In-Reply-To: <20081028164318.GD4819@sc.homeunix.net>

On Tue, 28 Oct 2008 16:43:19 +0000
Stephane Chazelas <Stephane_Chazelas@yahoo.fr> wrote:
> $ zsh -c '. -- --help'
> zsh:.:1: no such file or directory: --
> $ ARGV0=sh zsh -c '. -- --help'
> zsh:.:1: no such file or directory: --
> 
> The handling of "--" is mandated by POSIX I beleive.
> 
> With ksh, pdksh, bash you have to use:
> 
> . -- "$1"
> 
> if you can't guarantee that "$1" won't start with a "-".
> 
> Unfortunately, that code doesn't work with zsh at the moment.

This happens with builtins that are declared not to have any options.
I've noticed it before and thought it a bit flakey but been too craven
to fix it.  We don't document option processing rules anywhere that I
can find, so sticking with the standard is the only sensible bet.  It's
probably best to change for all such builtins.

We already changed this for the functionally similar case of "exec"
when that acquired options, so this should probably be considered
unfinished business.

This has probably missed 4.3.7, although that seems to be lost in the
post at the moment.

Index: README
===================================================================
RCS file: /cvsroot/zsh/zsh/README,v
retrieving revision 1.55
diff -u -r1.55 README
--- README	26 Oct 2008 17:59:48 -0000	1.55
+++ README	28 Oct 2008 20:45:41 -0000
@@ -35,6 +35,12 @@
 This section documents incompatibilities in the shell since the 4.2
 series of releases.
 
+In previous releases of the shell, builtin commands and precommand
+modifiers that did not accept options also did not recognize the
+argument "--" as marking the end of option processing without being
+considered an argument.  This was not documented and was incompatible
+with other shells.  All such commands now handle this syntax.
+
 The configuration option --enable-lfs to enable large file support has
 been replaced by autoconf's standard --enable-largefile mechanism.
 As this is usually used whenever necessary, this won't usually
Index: Src/builtin.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/builtin.c,v
retrieving revision 1.213
diff -u -r1.213 builtin.c
--- Src/builtin.c	18 Oct 2008 14:13:16 -0000	1.213
+++ Src/builtin.c	28 Oct 2008 20:45:43 -0000
@@ -391,6 +391,9 @@
 		if (ops.ind['-'])
 		    break;
 	    }
+	} else if (*argv && !strcmp(*argv, "--")) {
+	    ops.ind['-'] = 1;
+	    argv++;
 	}
 
 	/* handle built-in options, for overloaded handler functions */



-- 
Peter Stephenson <p.w.stephenson@ntlworld.com>
Web page now at http://homepage.ntlworld.com/p.w.stephenson/


  reply	other threads:[~2008-10-28 22:13 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-28 16:43 Stephane Chazelas
2008-10-28 21:49 ` Peter Stephenson [this message]
2008-10-29 11:11   ` 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=20081028214952.3bd0b64f@pws-pc \
    --to=p.w.stephenson@ntlworld.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).