从命令行获取TCL的版本?

时间:2022-09-13 00:10:35

I'm looking for a very straight-forward way of getting the version of the TCL installed on a machine from the command-line. For most programming languages, something along the lines of

我正在寻找一种非常直接的方式,从命令行获取安装在机器上的TCL版本。对于大多数编程语言来说,都是这样的

languagename -v

provides the information that I want. This does not seem to be an option for tclsh.

提供我想要的信息。这似乎不是tclsh的选择。

The TCL FAQ Q.B21 suggests

TCL常见问题问。B21建议

echo 'puts $tcl_version;exit 0' | tclsh

but I wonder if there is anything more straight-forward and cross-platform? (I suspect that this would fail mightily on a Microsoft Operating System.)

但我想知道是否还有更直接和跨平台的东西?(我怀疑这可能会在微软的操作系统上失败。)

--

- - -

EDIT: Just to emphasize that I'm looking for something that can be executed directly from the operating system command-line. There's all kinds of information available once you start tclsh, but I'm trying to avoid that to ease automated discovery.

编辑:只是为了强调我正在寻找可以直接从操作系统命令行执行的东西。一旦启动tclsh,就可以获得各种各样的信息,但我试图避免这种情况,以简化自动发现。

3 个解决方案

#1


38  

This might sound too simplistic, but if you made a script file that contained the commands:

这听起来可能过于简单,但是如果您创建了一个包含命令的脚本文件:

puts $tcl_version

And then ran tclsh sillyscript.tcl, that would execute on all platforms, assuming binary is in PATH. It certainly isn't fancy or flashy, or even neat, but it satisfies that requirement AFAIK.

然后就开始写些愚蠢的文字。假设二进制文件在路径中,tcl将在所有平台上执行。它当然不花哨,也不华丽,甚至不整洁,但它满足了这个要求。

====

= = = =

I got curious, so I tried it and without the quotes:

我很好奇,所以我尝试了一下,没有引用:

echo puts $tcl_version;exit 0 | tclsh

Executes just fine on my windows box... maybe platform detection prior to the TCL detection is an option?

在我的windows框上执行得很好……也许平台检测之前TCL检测是一个选择?

#2


20  

you can do this too.

你也可以这么做。

bash-3.2$ tclsh
% puts $tcl_version
8.6
% info patchlevel
8.6.0

but the best way i think is through echo.

但我认为最好的方式是通过echo。

echo 'puts [info patchlevel];exit 0' | tclsh
echo 'puts $tcl_version;exit 0' | tclsh

=======

= = = = = = =

weird when i tried with out the quotes it didn't work for me. running Mac osx

奇怪的是,当我试着引用它对我不起作用的引用时。运行Mac osx

#3


4  

Depending on your shell, it could be:

取决于你的外壳,它可能是:

tclsh <<< 'puts [info patchlevel]'

#1


38  

This might sound too simplistic, but if you made a script file that contained the commands:

这听起来可能过于简单,但是如果您创建了一个包含命令的脚本文件:

puts $tcl_version

And then ran tclsh sillyscript.tcl, that would execute on all platforms, assuming binary is in PATH. It certainly isn't fancy or flashy, or even neat, but it satisfies that requirement AFAIK.

然后就开始写些愚蠢的文字。假设二进制文件在路径中,tcl将在所有平台上执行。它当然不花哨,也不华丽,甚至不整洁,但它满足了这个要求。

====

= = = =

I got curious, so I tried it and without the quotes:

我很好奇,所以我尝试了一下,没有引用:

echo puts $tcl_version;exit 0 | tclsh

Executes just fine on my windows box... maybe platform detection prior to the TCL detection is an option?

在我的windows框上执行得很好……也许平台检测之前TCL检测是一个选择?

#2


20  

you can do this too.

你也可以这么做。

bash-3.2$ tclsh
% puts $tcl_version
8.6
% info patchlevel
8.6.0

but the best way i think is through echo.

但我认为最好的方式是通过echo。

echo 'puts [info patchlevel];exit 0' | tclsh
echo 'puts $tcl_version;exit 0' | tclsh

=======

= = = = = = =

weird when i tried with out the quotes it didn't work for me. running Mac osx

奇怪的是,当我试着引用它对我不起作用的引用时。运行Mac osx

#3


4  

Depending on your shell, it could be:

取决于你的外壳,它可能是:

tclsh <<< 'puts [info patchlevel]'