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

Re: mkdir builtin and $'\0'



On Tue, 18 Aug 2015 10:19:04 +0100
Stephane Chazelas <stephane.chazelas@xxxxxxxxx> wrote:
> $ zsh --version
> zsh 5.0.8 (x86_64-pc-linux-gnu)
> $ strace -e mkdir zsh -c "zmodload zsh/files; mkdir $'a\0b'"
> mkdir("a\203 b", 0755)                  = -1 EEXIST (File exists)
> zsh:mkdir:1: cannot make directory `a^@b': file exists
> +++ exited with 1 +++
> 
> See how that $'\0' became "\203 " except in the error message.

Looks like a long-standing mistake --- the unmetafied form of the
variable wasn't propagated everywhere.  A quick scan elsewhere suggests
this is just a one-off (I haven't confirmed in detail).

diff --git a/Src/Modules/files.c b/Src/Modules/files.c
index f86b9c1..dbcff63 100644
--- a/Src/Modules/files.c
+++ b/Src/Modules/files.c
@@ -131,7 +131,7 @@ domkdir(char *nam, char *path, mode_t mode, int p)
 	    return 0;
     }
     oumask = umask(0);
-    err = mkdir(path, mode) ? errno : 0;
+    err = mkdir(rpath, mode) ? errno : 0;
     umask(oumask);
     if(!err)
 	return 0;



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