From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jamie Lokier Subject: Re: [Qemu-devel] [PATCH] rev3: support colon in filenames Date: Wed, 15 Jul 2009 22:36:35 +0100 Message-ID: <20090715213635.GN3056@shareable.org> References: <4A434009.5010009@redhat.com> <1245998284.6278.99.camel@localhost> <4A447C8D.5000104@kevin-wolf.de> <1246063310.6278.115.camel@localhost> <1246511321.6429.31.camel@localhost> <4A4C754D.10109@redhat.com> <4A4CAD86.9020607@us.ibm.com> <4A4CB39F.5070506@redhat.com> <20090715181405.GB3056@shareable.org> <4A5E4206.20602@web.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Kevin Wolf , Anthony Liguori , linuxram@us.ibm.com, qemu-devel@nongnu.org, kvm-devel To: Jan Kiszka Return-path: Received: from mail2.shareable.org ([80.68.89.115]:35188 "EHLO mail2.shareable.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751883AbZGOVgk (ORCPT ); Wed, 15 Jul 2009 17:36:40 -0400 Content-Disposition: inline In-Reply-To: <4A5E4206.20602@web.de> Sender: kvm-owner@vger.kernel.org List-ID: 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 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: > > > > \ where 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