spaces in pathnames

Glynn Clements glynn at
Mon Jun 30 07:11:23 PDT 2008

Jeremy Huddleston wrote:

> So I just pushed a patch to xinit that addresses some issues with  
> spaces in pathnames.  One issue remains, and I'm not sure if there's a  
> clean way to address it.  At first, I thought I could do something  
> like this:
> -    serverargs=${serverargs}" -auth "${xserverauthfile}
> +    serverargs=${serverargs}" -auth '"${xserverauthfile}"'"
> but that doesn't work.  example:
> $ mya="Some thing with spaces"
> $ myargs="1 2 '$mya'"
> $ ./printargs $myargs
> argv[0] = ./printargs
> argv[1] = 1
> argv[2] = 2
> argv[3] = 'Some
> argv[4] = thing
> argv[5] = with
> argv[6] = spaces'
> So... any thoughts on how to overcome this cleanly?  And no, telling  
> people to not use spaces is unfortunately not an option... and neither  
> is hitting them over the head with a do-better stick.

IMHO, it's a lost cause.

The only clean solution is to use a language which has a list datatype
(or equivalent), as well as an "exec" primitive which accepts a list

It's practically impossible to get this 100% right if you're limited
to the Bourne shell.

You need to represent a list of strings, but the only datatype you
have available is a string, so you need a separator, but you also need
some way to represent the field separator when it occurs in a list
element. So you use quotes or an escape character, but then you need
to handle the case where the quote or escape characters appear in an

I can't say for certain that it's absolutely impossible, but any
solution will be both ugly and fragile.

Glynn Clements <glynn at>

More information about the xorg mailing list