From: Eli Z. <el...@gn...> - 2012-05-14 16:16:17
|
> Date: Thu, 10 May 2012 23:35:06 +0300 > From: Eli Zaretskii <el...@gn...> > > > Date: Thu, 10 May 2012 20:29:45 +0100 > > From: Keith Marshall <kei...@us...> > > > > The issue I intended to raise was not the escaping of quotes, but of > > globbing tokens. In any POSIX conforming glob(3) implementation, if > > GLOB_NOESCAPE is not set in the flags argument, any \ in the pattern > > will be parsed as an escape, so *, ?, and [, in \*, \?, and \[, lose > > their significance as globbing tokens. In a Windows implementation that > > becomes problematic, because \ is normally read as a directory name > > separator, which would make > > > > $ glob c:\foo\bar\*.* > > > > ambiguous, and I don't think we can realistically expect users to adapt > > to consistently using > > > > $ glob c:\foo\bar\\*.* > > > > as an unambiguous alternative. So, if we want GLOB_NOESCAPE to have any > > significance at all, (and I think it should), then we need to choose an > > alternative escape character, for use within the glob(3) implementation > > on which this improved command line globbing method depends. What > > character should we choose? ^ perhaps? Or should we expect cmd.exe to > > swallow that? Some other choice? I'm open to suggestions. > > '?' and '*' cannot appear in Windows file names, so the only issue is > with '['. And a literal '[' can be "escaped" by using [[]. So this > should let us have GLOB_NOESCAPE be a no-op. > > We could also use '^', but I personally don't see a compelling > reason. Am I missing something? The above was written in the context of globbing the Windows command line in the startup code of a typical MinGW program. Looking at the issue in a broader context, I do find a case for having a non-trivial GLOB_NOESCAPE functionality in MinGW 'glob': when someone needs to write code that provides strict Posix-compatible semantics of globbing file names. E.g., suppose that someone will make a native MinGW port of Bash, or write a library capable of interpreting Unix shell scripts. These kinds of applications will want to use a backslash as an escape character, as we see on Unix. If it is decided to include such a functionality in the MinGW 'glob', I think that, when GLOB_NOESCAPE is not set, the backslash should lose its role as directory separator entirely, and only forward slashes used for that purpose. The startup code will need by default to set GLOB_NOESCAPE in the flags, to support Windows-style file names. |