This is the mail archive of the cygwin mailing list for the Cygwin project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: execute a file in backslash notation from shell

On 02/12/2010 12:33 PM, Ilguiz Latypov wrote:

It never occurred to me that shells are unable to execute their first word in the Windows native backslash format,

   $ 'c:\cygwin\bin\echo.exe' test
   bash: c:\cygwin\bin\echo.exe: command not found

   $ ls -la 'c:\cygwin\bin\echo.exe'
   -rwxr-xr-x 1 ilatypov Domain Users 48128 2008-12-17 17:16 c:\cygwin\bin\echo.exe

I suspect that none of the shells was ever patched to attempt the "native Windows to POSIX" conversion on the first word of the command line.

Ideally, the patches would not be necessary had the shells used a
filename  translation/detection/manipulation API. But Posix does not seem to provide a
complete API for this.

Alternatively, the shells could attempt to execute the first word as a
program through the exec..() family of C library calls.

Instead, bash and pdksh execute the first word of the command line in
the  following cases.

   (a) The first word has forward slashes.
   (b) Concatenation of the first word against elements of PATH points
      (probably, with addition of default suffixes) to an existing file.

I am attaching a patch to pdksh that allows to execute the first word in
backslash notation. This might be necessary for GNU make based build systems
that could pass a backslash filename to SHELL as a command.

Thanks but the point of Cygwin is that individual applications shouldn't need altering in order to build and run. The intent is also to provide a POSIX environment supporting POSIX paths. The Cygwin DLL provides some facilities to convert POSIX<->DOS paths. This can be invoked directly using the 'cygpath' utility or Cygwin will do it transparently generally, but you have to properly quote the path (i.e. escape the backslashes or enclose the whole path inside ' '). There are some limitations to the transparent handling of DOS paths, since this requires detecting that the path is DOS. Some conventions of DOS paths conflict with that of POSIX. In those cases, the algorithm comes down on the side of POSIX. But 'cygpath' can always be used to help in these cases.

Larry Hall                    
RFK Partners, Inc.                      (508) 893-9779 - RFK Office
216 Dalton Rd.                          (508) 893-9889 - FAX
Holliston, MA 01746


A: Yes.
> Q: Are you sure?
>> A: Because it reverses the logical flow of conversation.
>>> Q: Why is top posting annoying in email?

Problem reports:
Unsubscribe info:

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]