* [PATCH] unmetafy $_ when exporting it to child
@ 2023-04-06 6:22 Jun T
0 siblings, 0 replies; only message in thread
From: Jun T @ 2023-04-06 6:22 UTC (permalink / raw)
To: zsh-workers
While testing my patch for the initialization of $_, I've noticed
that zsh exports _ to child without unmetafying pwd.
For example:
% mkdir -p /tmp/漢字 && cd /tmp/漢字
% echo $'#!/bin/ksh\necho $_' > foo
% chmod u+x foo
% ./foo | od -t c -t x1
0000000 / t m p / 346 274 203 202 345 255 203 267 / . /
2f 74 6d 70 2f e6 bc 83 82 e5 ad 83 b7 2f 2e 2f
0000020 f o o \n
66 6f 6f 0a
% echo 漢字 | od -t c -t x1
0000000 346 274 242 345 255 227 \n
e6 bc a2 e5 ad 97 0a
You can see that 'echo $_' outputs metafied value: a2 -> 83 82.
BTW, if we use ksh
% ksh
$ ./foo
./foo
So zsh exports _=/tmp/漢字/./foo, but ksh exports _=./foo.
diff --git a/Src/exec.c b/Src/exec.c
index 4328975b9..3b3d1235e 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -519,7 +519,7 @@ zexecve(char *pth, char **argv, char **newenvp)
if (*pth == '/')
strcpy(buf + 2, pth);
else
- sprintf(buf + 2, "%s/%s", pwd, pth);
+ sprintf(buf + 2, "%s/%s", unmeta(pwd), pth);
zputenv(buf);
#ifndef FD_CLOEXEC
closedumps();
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-04-06 6:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-06 6:22 [PATCH] unmetafy $_ when exporting it to child Jun T
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).