Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
mkdir builtin and $'\0'
- X-seq: zsh-workers 36217
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: mkdir builtin and $'\0'
- Date: Tue, 18 Aug 2015 10:19:04 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:subject:message-id:mail-followup-to:mime-version :content-type:content-disposition:content-transfer-encoding :user-agent; bh=ljbzqRrkmGAYvV/tuXZILgltFWDqD2hjAa22eOjVLQY=; b=pYt2+7jyN4+JkQN/ZEUaVuLmpkxICGgA0zQW13cGn+Lg3HtPzMpQG01RPCB5lngLYW yH1jrh+N1016OlBlHHWaanbG+wLVh7Kjd8oX03150HSB621GdDW8TXyZ4XIgq/OGSGj+ ipvrbDr6T1Su58c2T80fmWcIfCyvWl4xaWZtkGUKWY9NBXSDl1kEyIgaJ+440Y0MF+tJ pIeyzZ2NYVtVgsPE9jW9yuc6SUjiwlJ+ft4dwxzlQ8+A+OxuY+X5Elfq1y8zTSaXV5R3 Rn49jIaZpwAih0i677xiOBO/BHWteA6TumRK1y9CHYRqCGSGBwUHMEKMfcR3Su6jXDtI CWBg==
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
$ 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.
Not a big problem in that nothing good will ever come out of
mkdir $'\0' anyway since one can't pass a NUL character to the
mkdir() system call.
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
chdir("..") = 0
chdir("..") = 0
chdir("..") = 0
chdir("/home/stephane/a\203 b") = 0
/export/home/stephane/a
/home/stephane/a� b
+++ exited with 0 +++
I suppose the chdir("..")s come after the realisation that $PWD
probably doesn't represent the current directory anymore (since
chdir("$PWD/dir") doesn't work while chdir("dir") does).
"mv" at least doesn't have the problem. A note though:
$ strace -e rename zsh -c "zmodload zsh/files; mv $'a\0b' x"
rename("a", "x/a") = -1 ENOENT (No such file or directory)
zsh:mv:1: a^@b: no such file or directory
+++ exited with 1 +++
The error message mentions a^@b not existing while it did
attempt to rename "a" instead.
Maybe those builtins should fail with an error if one attempts
to call them with an argument containing NUL.
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author