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]

execute a file in backslash notation from shell

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.

Attachment: sh.exe-pdksh-5.2.14-3-abs-win-arg0.txt
Description: Text document

Problem reports:
Unsubscribe info:

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