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

Re: null bytes in file names?



Erik Trulsson wrote:
> On Mon, Apr 07, 2003 at 10:32:21AM +0200, Dominik Vogt wrote:
> > As far as I know, UNIX file systems allow null bytes in file
> > names.  Out of curiosity I tried generating such a file.  I edited
> > a file fn in a hex editor and put a single null byte into it.
> 
> Your knowledge is somewhat faulty.
> There are exactly two characters that Unix does not allow in filenames.
> Those are NUL (ASCII code 0) and / (ASCII code 47).
> The former is used to indicate the end of a filename, while the latter
> is used to separate directory paths.

Just to be particular...

> > Take I (with "touch"):
> > 
> >   $ touch $(< fn)
> >   touch: creating `': No such file or directory
> >   touch: creating `': No such file or directory

...zsh actually handles the NUL internally, but there's no way to pass
it down as an argument to `touch'.  That gets passed a string `NUL
NUL'.  However, since as you no doubt know all the command receives is a
count of arguments and a series of null-terminated strings, touch simply
sees the first NUL.  The same would happen with an `open()' call from
within zsh.  That's where the rule Erik mentioned comes from.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************



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