![使 bash 脚本仅输出(类型)而不执行](https://linux22.com/image/185885/%E4%BD%BF%20bash%20%E8%84%9A%E6%9C%AC%E4%BB%85%E8%BE%93%E5%87%BA%EF%BC%88%E7%B1%BB%E5%9E%8B%EF%BC%89%E8%80%8C%E4%B8%8D%E6%89%A7%E8%A1%8C.png)
我正在尝试编写一个 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>