cygwin 上的 Auto_execok 问题
我有一个问题: auto_execok
命令无法按预期在 Cygwin 平台上运行。 它无法从您的 PATH
环境变量中找到任何内容,因为
info body auto_execok
"...
foreach dir [split $path {;}] {
"
它默认认为 ;
是正确的分隔符,但 Cygwin 使用 :
! 如何优雅地克服这个问题呢? 我不想更改 PATH
变量,因为其他程序/脚本可以正确使用 :
,因为它应该适用于 Cygwin。
I have a problem:
the auto_execok
command doesn't work on Cygwin platform as expected.
It cannot find anything from your PATH
enviroment variable, as
info body auto_execok
"...
foreach dir [split $path {;}] {
"
It thinks by default that ;
is right separator, but Cygwin uses :
!
How to elegantly overcome this problem?
I don't want to change PATH
variable as other programs/scripts could correctly use :
as it should be for Cygwin.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否有正确的支持 Cygwin 的 Tcl 构建?正如您所发现的,直接 Windows 构建会遇到问题,正是因为 Cygwin 环境是 Unix 和 Windows 之间的混合体。 (这是为什么我们不完全支持在 Cygwin 中做事的一个例子;它时不时地受到一些人的喜爱,但它不是一个主要平台,因为它非常复杂。)也就是说,这是一种问题几乎可以肯定,在 comp.lang.tcl 上询问会更好这有一个社区可能会能够帮助解决这类事情。
另外,这是什么Tcl补丁级别?这很重要,因为支持水平肯定会随着时间的推移而变化……
Have you got a proper Cygwin-aware build of Tcl? As you've found, a straight Windows build runs into problems precisely because the Cygwin environment is a sort of mix between Unix and Windows. (This an example of why we don't fully support doing things in Cygwin; it gets some love from time to time, but it's not a primary platform because it is fully of fiddly complexities.) That said, this is the sort of question which it is almost certainly better to ask on comp.lang.tcl as that's got a community likely to be able to help with this sort of thing.
Also, what patch-level of Tcl is this? This matters because the level of support has most certainly varied over time…
我们可以混合使用
set ar [info args auto_execok]
、set bd [info body auto_execok]
、使用
set cygdir [exec cygpath -a $wdir]
和eval proc auto_exeok {$ar} {$bd}
在主体上进行一些 regsub 以获得所需的结果。然而,目前我还没有准备好完整的解决方案。
We can use a mix of
set ar [info args auto_execok]
,set bd [info body auto_execok]
,some regsub on body with
set cygdir [exec cygpath -a $wdir]
andeval proc auto_exeok {$ar} {$bd}
to obtain needed result.However, for the moment, I'm not yet ready with the complete solution.
您可以使用能够解析正确路径的版本来包装 auto_execok 的本机 tcl 版本。我们可以利用这样一个事实:原始的 auto_execok 会找到 cygpath.exe,并一举告诉用户当前脚本正在运行 Windows,并且它是为 cygwin 设置的。一旦知道了这一点,我们就可以用一个将使用 cygpath.exe 解析真实 Windows 路径的过程来包装原始的 auto_execok 过程。我使用了 try 命令,因此这是针对 8.5 及更高版本的,但对于较低版本的 tcl 可以使用 catch 编写。另外,因为使用了 subst 命令,所以 cygpath 的路径被硬编码到新的 auto_execok 过程中,因此查找仅发生一次。也只允许此代码运行一次。举个例子
在下面的代码运行之前
puts "[ auto_execok tar ]"
给出
“/usr/bin/tar”
代码运行后
auto_execok 被包装:
puts “[ auto_execok tar ]”
给出(在我的机器上):
“C:/cygwin/bin/tar.EXE”
}
You can wrap the native tcl version of auto_execok with one that will resolve the correct path. We can use the fact that the original auto_execok will find the cygpath.exe and in one fell swoop tell use that the current script is running windows and it is setup for cygwin. Once that it is known we can wrap the original auto_execok proc with one that will use cygpath.exe to resolve the true windows path. I have used the try command so this is for 8.5 and above but this can be written using catch for lower versions of tcl. Also because subst command is used the path to cygpath is hardcoded into the new auto_execok proc so lookup only happens once. Also only allow this code to run once. So as example
before code below runs
puts "[ auto_execok tar ]"
gives
"/usr/bin/tar"
after code is run auto_execok is wrapped:
puts "[ auto_execok tar ]"
gives (on my machine):
"C:/cygwin/bin/tar.EXE"
}