zsh-workers
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@zsh.org
Subject: The -~ bug
Date: Fri, 2 Dec 2016 16:37:30 -0800	[thread overview]
Message-ID: <161202163730.ZM2895@torch.brasslantern.com> (raw)

The problem is that '-' is still tokenized as Dash on entry to filesubstr()
in subst.c.

This is going to break zstrtol() as well, for e.g. ~-3 counting backwards
in the stack, which is done very early before the rest of the filename has
been examined.

But we don't want to untokenize the entire file name; tokens like Brack
and Equals are still important.

Is it safe to do the following, which changes the string passed in via
*namptr?  Or is it necessary to dupstring()?

diff --git a/Src/subst.c b/Src/subst.c
index 06d2c9e..64b4400 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -650,6 +650,8 @@ filesubstr(char **namptr, int assign)
 	char *ptr, *tmp, *res, *ptr2;
 	int val;
 
+	if (str[1] == Dash)
+	    str[1] = '-';
 	val = zstrtol(str + 1, &ptr, 10);
 	if (isend(str[1])) {   /* ~ */
 	    *namptr = dyncat(home ? home : "", str + 1);


             reply	other threads:[~2016-12-03  0:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-03  0:37 Bart Schaefer [this message]
2016-12-03 19:57 ` Peter Stephenson

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=161202163730.ZM2895@torch.brasslantern.com \
    --to=schaefer@brasslantern.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).