views:

15

answers:

3

as an replacement for ksh under cygwin, pdksh might be the only choice. but look like there have a bug for cygwin : pdksh(5.2.14-3) to support backslash path (\).

it will swallow the \ :

$ cd .\access
pdksh: cd: /cygdrive/e/.access - No such file or directory

After search on the internet, the same problem solved for other platform. but no idea how to solve it for cygwin.

A: 

You have to use forward slashes, or double all the backslashes, or single-quote every string that might be a pathname. Sorry, there's no way around this. This is a general problem with trying to use Unix shells, for which \ is an escape character, on Windows.

Zack
A: 

From the Cygwin User's Guide:

Note

The usage of Win32 paths, though possible, is deprecated, since it circumvents important internal path handling mechanisms. See the section called “Using native Win32 paths” and the section called “Using the Win32 file API in Cygwin applications” for more information.

There is a utility called cygpath that is designed to be used in shell scripts that converts each way between Win32 and POSIX paths.

Dennis Williamson
A: 

Pdksh, like all Cygwin programs, does support backslashes as directory separators. But you have to quote them properly. Running shell scripts under Cygwin really teaches you to quote things properly, in particular to always put variable substitutions in double quotes, and not use echo carelessly (printf "%s" "$x" is portable and reliable: unlike echo, there's no risk that it might do backslash expansion).

Note that pdksh's compatibility with even ksh88 is far from perfect, so some scripts may fail for other reasons (such as relying on the status code of writer | reader being that of reader, which is the case in true ksh but not in pdksh). Cygwin includes zsh, which after you run emulate ksh is mostly compatible with ksh88 (though still not perfect).

There are non-Cygwin ports of ksh for Windows, including InterixSFUSUA and ATT's own port.

Gilles