* expansion bug in 4.0.3?
@ 2001-11-03 8:00 Danek Duvall
2001-11-03 16:43 ` PATCH: " Bart Schaefer
0 siblings, 1 reply; 4+ messages in thread
From: Danek Duvall @ 2001-11-03 8:00 UTC (permalink / raw)
To: zsh-workers
This example is easily reconstructed on Linux:
% echo $$
146
% print -l ${$(</proc/$$/environ)}
DISPLAY=:0.0 HOME=/home/duvall LOGNAME=duvall USER=duvall [ ... ]
% print -l ${$(</proc/146/environ)}
DISPLAY=:0.0
HOME=/home/duvall
LOGNAME=duvall
USER=duvall
[ ... ]
The only difference is that in one case the filename is specified with a
parameter, in the other, without. If, in the former case, I explicitly
split on spaces:
% print -l ${(s: :)$(</proc/$$/environ)}
then I get the output I want. Alternatively, if I skip the outer
braces:
% print -l $(</proc/$$/environ)
then the output also comes out on multiple lines.
(For those not on Linux, this file contains fields separated by null
characters.)
Is this a bug, or is there some behavior I'm not understanding properly?
Thanks,
Danek
^ permalink raw reply [flat|nested] 4+ messages in thread
* PATCH: Re: expansion bug in 4.0.3?
2001-11-03 8:00 expansion bug in 4.0.3? Danek Duvall
@ 2001-11-03 16:43 ` Bart Schaefer
2001-11-03 17:13 ` Bart Schaefer
2001-11-03 20:35 ` [16215] " Danek Duvall
0 siblings, 2 replies; 4+ messages in thread
From: Bart Schaefer @ 2001-11-03 16:43 UTC (permalink / raw)
To: Danek Duvall, zsh-workers
On Nov 3, 12:00am, Danek Duvall wrote:
}
} % echo $$
} 146
} % print -l ${$(</proc/$$/environ)}
} DISPLAY=:0.0 HOME=/home/duvall LOGNAME=duvall USER=duvall [ ... ]
} % print -l ${$(</proc/146/environ)}
} DISPLAY=:0.0
} HOME=/home/duvall
} LOGNAME=duvall
} USER=duvall
} [ ... ]
}
} Is this a bug, or is there some behavior I'm not understanding properly?
It's a bug. The optimization that causes $(<filename) to be implmented
without forking is not properly saving/restoring some state, such that
the expansion of $$ in the file name causes zsh to behave as if you'd
written it with double quotes, i.e. `print -l ${"$(</proc/$$/environ)"}'.
This bug doesn't exist in 3.0.x because the state that needs to be saved
and restored wasn't introduced until 3.1.9-pws-19. However, the bug has
probably been present ever since then -- for more than two years.
The following would appear to be the fix. "make check" still passes.
Index: Src/subst.c
===================================================================
--- Src/subst.c 2001/10/17 14:38:29 1.8
+++ Src/subst.c 2001/11/03 16:34:57
@@ -245,11 +245,13 @@
mod_export void
singsub(char **s)
{
+ int omi = mult_isarr;
local_list1(foo);
init_list1(foo, *s);
prefork(&foo, PF_SINGLE);
+ mult_isarr = omi;
if (errflag)
return;
*s = (char *) ugetnode(&foo);
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: PATCH: Re: expansion bug in 4.0.3?
2001-11-03 16:43 ` PATCH: " Bart Schaefer
@ 2001-11-03 17:13 ` Bart Schaefer
2001-11-03 20:35 ` [16215] " Danek Duvall
1 sibling, 0 replies; 4+ messages in thread
From: Bart Schaefer @ 2001-11-03 17:13 UTC (permalink / raw)
To: Danek Duvall, zsh-workers
On Nov 3, 4:43pm, Bart Schaefer wrote:
}
} This bug doesn't exist in 3.0.x because the state that needs to be saved
} and restored wasn't introduced until 3.1.9-pws-19.
^
That should say "3.1.6-pws-19", of course.
--
Bart Schaefer Brass Lantern Enterprises
http://www.well.com/user/barts http://www.brasslantern.com
Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [16215] PATCH: Re: expansion bug in 4.0.3?
2001-11-03 16:43 ` PATCH: " Bart Schaefer
2001-11-03 17:13 ` Bart Schaefer
@ 2001-11-03 20:35 ` Danek Duvall
1 sibling, 0 replies; 4+ messages in thread
From: Danek Duvall @ 2001-11-03 20:35 UTC (permalink / raw)
To: zsh-workers
On Sat, Nov 03, 2001 at 04:43:31PM +0000, Bart Schaefer wrote:
> The following would appear to be the fix. "make check" still passes.
That does the trick. Thanks!
Danek
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2001-11-03 20:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-03 8:00 expansion bug in 4.0.3? Danek Duvall
2001-11-03 16:43 ` PATCH: " Bart Schaefer
2001-11-03 17:13 ` Bart Schaefer
2001-11-03 20:35 ` [16215] " Danek Duvall
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).