[darcs-users] Whitespace in filenames

David Roundy droundy at jdj5.mit.edu
Fri Aug 1 14:35:12 UTC 2003


On Thu, Jul 31, 2003 at 12:26:00PM +1000, Donald Bruce Stewart wrote:
> This also revealed that darcs doesn't like whitespace in file
> names, this seems reasonably easy to fix (haven't done this yet,
> though).

When designing the patch formats, I thought about whitespace in file names,
and couldn't think of a good reason to allow it.  Since I couldn't see any
way to allow whitespace other than escaping it (which meant also escaping
the escape character--probably '\'. which has the advantage that you really
shouldn't be using '\' in your filenames if you want your code to be
portable), I decided against it, mostly because I didn't want to bother.

Is whitespace in filenames something that people tend to use? I think I've
seen it in kde once, but it seems like a silly thing to have... On the
other hand, I also thought it was silly to have filenames starting with
'.', and I just ran into all sorts of trouble tracking down a bug caused by
*that*.

I guess it's probably better to support whitespace in filenames just so we
don't have to worry about the issue.  It just takes writing three parsing
routines to parse filenames (one for direct from a Handle, one from String
and one from PackedString) and a couple printing routines (which could share
code), and making sure they are used throughout the parsing and patch
printing/showing code.

I guess it would be simplest to escape in the following way:
print_filename f = concat $ map escape f
  where escape '\\' = "\\\\"
        escape c = if Char.isWhiteSpace c
                   then "\\" ++ c
                   else [c]
-- 
David Roundy
http://www.abridgegame.org




More information about the darcs-users mailing list