使 bash 脚本仅输出(类型)而不执行

使 bash 脚本仅输出(类型)而不执行

我正在尝试编写一个 bash 脚本来帮助用户在终端中输入命令。但是,我希望该命令不被执行。这是一个简单的例子:

#!/bin/sh

function type_for_me() {
  line_number = ( ... do some calculation ...)  # let's say line_number is 25
  if [[ -n $line_number ]]; then
    echo "generates some complex cmd with $line_number"  # I want this line to appear in terminal but un-executed.
  fi
}

运行命令后,我正在寻找以下行为:

$ type_for_me
$ generates some complex cmd with 25  # this line waits for user to hit <Enter>

相关内容