开发者

Korn-Shell for Windows 7?

开发者 https://www.devze.com 2023-01-03 18:12 出处:网络
We need to support a legacy app that provides a Unix and a Win32 port.Unfortunately, later in the game, a lot of glue code was written in ksh scripts for the unix port only, and the Win32 port has los

We need to support a legacy app that provides a Unix and a Win32 port. Unfortunately, later in the game, a lot of glue code was written in ksh scripts for the unix port only, and the Win32 port has lost parity. I've been trying to revive it, and I've been trying some ksh-for-wi开发者_如何学Cndows solutions (a native build of Zsh used to work in the past), but nothing seems to work properly under Windows 7: Cygwin refuses to use both Win32 and unix-style paths, so some convoluted scripts break. Same situation for SUA/SFU. UWin doesn't work on Windows 7. The older native ports I used to use (WinZsh) also no longer work under 7.

So, I am in need of a Korn-shell work-alike that will work under Win 7 (64 bit would be awesome, but I've lost hope) and which can work with both cmd.exe-style paths (c:/path/to/app) and standard Unix paths (/path/to/app). Any clues?


Cygwin luckily replaced pdksh (dead since 1999) with mksh. However, mksh will *not* support non-POSIX paths, as it’s primarily a BSD Unix shell, and one of its strengths is working the same across all platforms.

That being said, there’s dos2unixpath and unix2dospath (IIRC) in Interix. Maybe you can use them.

Something like this might even work:

function dos2unixpath {
    local _x=$1
    [[ $_x = [A-Za-z]:[\\/]* ]] && _x=/dev/fs/${_x::1}/${_x:3}
    print -r -- "${_x//\\//}"
}

This converts x:\foo\bar to /dev/fs/x/foo/bar, ..\bla to ../bla, and leaves the rest alone.


Cygwin does support C:/path/to/app style paths, even though it likes to complain about them. (Setting CYGWIN=nodosfilewarning will shut it up). Even paths with backslashes are supported, but they need appropriate quoting to stop the shell from interpreting them.

Pdksh, the "Public Domain Korn Shell", can be installed through Cygwin's setup.exe.

0

精彩评论

暂无评论...
验证码 换一张
取 消