在 tcl 中使用特定版本的 http

Use specific version of http in tcl

我目前正在 Ubuntu 20.04 上开发。我正在使用 http 版本 2.9.1 附带的当前最新版本的 tcl。但是我需要使用特定版本的 http 包,即 2.8.9。当我使用指令时:

package require http -exact 2.8.9

我收到一条错误消息,提示找不到包 http 2.8.9。有什么方法可以下载特定的 http 包,然后在我的脚本中使用它。或者有没有办法将 tcl 降级到早期版本。或下载较早版本的tcl,然后指定使用哪个版本。

你可以从github镜像中抓取:https://github.com/tcltk/tcl/blob/core-8-6-6/library/http/http.tcl

  1. 将该版本另存为 http.tcl 在目录中,比如 /path/to/my/http
  2. cd /path/to/my/http
  3. echo "pkg_mkIndex ." | tclsh

然后,在你的 tcl 脚本中:

lappend auto_path /path/to/my/http
package require -exact http 2.8.9

您还可以 lappend auto_path /path/to/my -- 程序包加载器在 $auto_path 中的目录以及这些目录的直接子目录中查找 pkgIndex.tcl 文件。使用 /path/to/my 允许您在该父目录下拥有其他自定义包目录