Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] unmetafy $_ when exporting it to child



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();








Messages sorted by: Reverse Date, Date, Thread, Author