allow executing a path in backslash notation

Eric Blake eblake@redhat.com
Wed Mar 10 15:39:00 GMT 2010


On 03/10/2010 03:54 AM, Andy Koppe wrote:
>>> $ builtin exec "$WINDIR\system32\cmd.exe" /C echo ok
>>> -bash: exec: C:\WINDOWS\system32\cmd.exe: not found
>>>
>> Is it me, or is the quoting all wrong? Doesn't backslash in the double
>> quote (") acts as an escape character. i.e \s = s, \c = c etc.
> 
> http://www.gnu.org/software/bash/manual/bashref.html#Double-Quotes:
> The backslash retains its special meaning only when followed by one of
> the following characters: ‘$’, ‘`’, ‘"’, ‘\’, or newline.

That's bash's rules.  According to POSIX, "\n" has undefined behavior.
And in some other implementations, such as Solaris sh, "\n" is
interpolated by the shell as a newline.  Bash instead does the
interpolation when you use $'\n'.

But the moral of the story is that within "", it is only portable to use
\ if it is followed by one of the four bytes specifically documented by
POSIX.

-- 
Eric Blake   eblake@redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 323 bytes
Desc: OpenPGP digital signature
URL: <http://cygwin.com/pipermail/cygwin/attachments/20100310/0b02ef9e/attachment.sig>


More information about the Cygwin mailing list