tcl - 是否有 tcl 命令可以在脚本中启动 shell 提示符

标签 tcl

我有一个 tcl 脚本,在执行点和给定条件下,我想要启动提示符 (%) 的选项。

类似的东西

# ... previous program logic
if { some_condition } {
   # start shell prompt within current execution context
}
else 
  # continue execution

谢谢。

最佳答案

也许最好使用 tclreadline 包在脚本中启动提示!

类似这样的东西:

package require tclreadline

# ... previous program logic
if { some_condition } {
   # Start the shell prompt
   set prompt "% "
   while {[gets [tclreadline::readline $prompt] line] != -1} {
      # Handle user input
      # ...
   }
}
else {
  # continue execution
  # ...
}

如您所见,我首先加载 tclreadline 包,如果 some_condition 为 true,我会启动一个 while 循环,反复提示用户使用 tclreadline::readline 命令进行输入!

祝你好运!

关于tcl - 是否有 tcl 命令可以在脚本中启动 shell 提示符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76568625/

相关文章:

tcl - 读取换行

tcl - 在文件中查找搜索字符串并打印该行中的下一个单词

c++ - 如何将 C++ unsigned char [] 传递给 Tcl bytearray?

linux - exec 命令被卡住

tcl - 我们可以在 tclOO 中定义静态函数吗?

awk - 我想从 tcl 脚本执行 awk 命令

memory - 应该给 Tcl dict 什么值以获得最小内存?

TCL 假卡在退出

sorting - tcl 有部分排序命令吗?

tcl - 是否可以更改笔记本标签的宽度?