Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
The -~ bug
- X-seq: zsh-workers 40071
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: The -~ bug
- Date: Fri, 2 Dec 2016 16:37:30 -0800
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:to:subject:mime-version; bh=8fzjLFpAcKyXfrTBY+txjbzEHHef6bmNjhqW/fbEO40=; b=HDk1NmMqMV0M7oeom40flseetR5xdXHB80QqqVAVJ+LTZ7EzSv0wLOQcWsCJ+zPklO lGqiPOjcxqTYL0+Aw1U4QyIEDTRePBZuaO+8RZcj0LkYu5PLgvzz7g5GN/h8fjOpSYS+ 1GPcPpa+TQPxh9kvI+pJ9593JWFgP8mxc5+9QsTRhKNYKeWNn6sgjtg76r/MoWL5ykoF yf5i2WInfb+GIaH8XXfImJU6XFGKeYrKDbGg9/+xw+mh0H1BiFPOma0Dhsg3Jn8bMgxv o10JSmpkUvdXGKkdKpXesn761r08RepPFqaM6nlAHadYRhcV9Pg6Yoh/tJPol8J1vysb K+VA==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
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);
Messages sorted by:
Reverse Date,
Date,
Thread,
Author