有没有办法从bash函数调用强制回显到命令行?

ast*_*eri 2 bash shell stdout echo

我有一个bash脚本,我用一个很好的编程风格定义了一堆函数.这些函数通过echo它们"返回"值.所以,例如:

some_function() {
   echo "I like pie."
}

what_do_i_like=`some_function`
Run Code Online (Sandbox Code Playgroud)

现在,我想在我的函数中添加一些调试语句.不幸的是,我echo只是被变量中的调用者捕获了.例如,

some_function() {
    if [[ "${DEBUG}" = "${TRUE}" ]]; then
        echo "We're about to find out what we like."
    fi
    echo "I like pie."
}

what_do_i_like=`some_function`
Run Code Online (Sandbox Code Playgroud)

...调试语句被捕获在what_do_i_like变量中.

有什么方法可以绕过这个并强行打印到命令行并且输出没有被捕获到变量中吗?

Joh*_*024 5

echo "We're about to find out what we like." >/dev/tty
Run Code Online (Sandbox Code Playgroud)