From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 20611 invoked by alias); 18 Aug 2015 09:19:12 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36217 Received: (qmail 202 invoked from network); 18 Aug 2015 09:19:11 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.0 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== X-Received: by 10.194.204.163 with SMTP id kz3mr11522768wjc.28.1439889546408; Tue, 18 Aug 2015 02:19:06 -0700 (PDT) Date: Tue, 18 Aug 2015 10:19:04 +0100 From: Stephane Chazelas To: Zsh hackers list Subject: mkdir builtin and $'\0' Message-ID: <20150818091904.GA5389@chaz.gmail.com> Mail-Followup-To: Zsh hackers list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.5.21 (2010-09-15) $ 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