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

Re: mkdir builtin and $'\0'



On Tue, Aug 18, 2015 at 6:37 PM, Peter Stephenson
<p.stephenson@xxxxxxxxxxx> wrote:
> On Tue, 18 Aug 2015 17:20:40 +0100
> Stephane Chazelas <stephane.chazelas@xxxxxxxxx> wrote:
>> 2015-08-18 10:19:04 +0100, Stephane Chazelas:
>> [...]
>> > A bit worse:
>> >
>> > $ strace -e chdir zsh -c "cd $'a\0b'; print -r -- \$PWD; pwd"
>> > chdir("/export/home/stephane/a")        = -1 ENOENT (No such file or directory)
>> > chdir("a\203 b")                        = 0
>
> Looks like that's this one (igroning for now the silent use of embedded
> nulls).
>
> diff --git a/Src/compat.c b/Src/compat.c
> index b3a8b06..a0ce182 100644
> --- a/Src/compat.c
> +++ b/Src/compat.c
> @@ -465,7 +465,7 @@ zchdir(char *dir)
>      int currdir = -2;
>
>      for (;;) {
> -       if (!*dir || chdir(dir) == 0) {
> +       if (!*dir || chdir(unmeta(dir)) == 0) {
>  #ifdef HAVE_FCHDIR
>             if (currdir >= 0)
>                 close(currdir);

[replying to the correct thread]

% mkdir /tmp/ホ
% cd /tmp/ホ
cd: no such file or directory: /tmp/ホ
% cd /tmp
% cd ホ
% pwd
/tmp/ホ
% echo ホ|xxd
00000000: e383 9b0a

> It doesn't happen with all japanese characters. I'm hoping one of
> those bytes in the output mean something to you. I'm also assuming
> this is related to the recent fudging of unmetafy in chdir().

I just checked and
% octtohex 203
0x83

this is the \203 from the chdir strace above, and 83 from the middle
of my character. Do we have inconsistent metafication in this string
somehow?

-- 
Mikael Magnusson



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