Re: [Qemu-devel] [PATCH] rev3: support colon in filenames

Jamie Lokier
2009-07-15T21:36:40Z

Jan Kiszka wrote:
> > Now, I see one significant hurdle with that: it's quite inconvenient
> > for Windows users, typing paths like c:\path\to\dir\file, if those
> > backslashes are stipped.
>
> We could exclude Windows from this (I think to remember that filenames
> are more restricted there anyway) or define a different, Windows-only
> escape character.

I think both of those are bad ideas, because the same management
scripts can run on Windows, and for consistency it's not just file
names. Even Windows has block devices and network devices :-)

Fortunately "where <char> is not ASCII alphanumeric" solves the
practical cases where the user types an ordinary pathname.

Or the user can type forward slashes just like they do in unix.

> > So I propose this as a universal quoting scheme:
> >
> > \<char> where <char> is not ASCII alphanumeric.
> >
> > Shell quoting is easy:
> >
> > qfile=`printf %s "$file" | sed 's/[^0-9a-zA-Z]/\\\\&/g'`
> >
> > qemu -drive file="$qfile",if=scsi,media=disk

I forgot a very obscure corner case, where the last character of the
filename is a newline character. To do the right thing (with Bash at
least), it should say '%s\n' instead of %s. Sue me :-)

> > Same quoting applied when sending the monitor a command to change a
> > CD-ROM file or add a USB disk, for example.
>
> To me this direction looks more promising than any other proposal so far.

I wondered if it was just me...

-- Jamie