Korn-Shell for Windows 7?

左心房为你撑大大i 提交于 2019-12-09 07:28:48

问题


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-windows 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?


回答1:


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.




回答2:


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.



来源:https://stackoverflow.com/questions/3068585/korn-shell-for-windows-7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!