【发布时间】:2015-06-11 09:35:00
【问题描述】:
我想从 Subversion HTTP URL 中删除一些额外的文件/文件夹级别以在 Tcl 脚本中获取分支根 URL。
例如:
http://svn.example.com/repos/trunk/file.tcl
-->
http://svn.example.com/repos/trunk/
我尝试使用file dirname 命令,但遇到了一些“意外行为”(至少从我的角度来看):
file dirname {http://svn.example.com/repos/trunk/file.tcl}
返回(Windows 7,来自 Altera Quartus 发行版的 Tcl 8.5):
http:svn.example.com/repos/trunk
网址前缀的“//”斜线已被删除!?!
在其他 Tcl 版本(Windows 7、Cygwin / Linux 的 Tcl 8.5、Tcl 8.5)中,我得到了不同但仍然不正确的结果:
http:/svn.example.com/repos/trunk
(两个“//”斜杠中的一个“/”已被删除)
为什么会有这样的结果?
还有其他选择吗?(除了使用string last、string range...的自定义函数)
注意:file separator 命令根据版本返回不同的结果:
- “
\”在来自 Altera Quartus 的 Windows “native” Tcl 中; - “
/”在 Tcl Cygwin / Linux 版本中。
【问题讨论】: