我需要帮助将系统命令的输出(stdin和stdout)发送到bash函数中,同时仍然接受来自参数的输入。就像以下示例一样。有人能给我指点一下正确的方向吗?
LogMsg()
{
DateTime=`date "+%Y/%m/%d %H:%M:%S"`
echo '*****'$DateTime' ('$QMAKESPEC'): '$1 >> "$LogFile"
echo $DateTime' ('$QMAKESPEC'): '$1
}
# Already works
LogMsg "This statement is sent directly"
# Wish I could do this:
# Capture both stdout & stderr of a system function to the logfile
# I do not presume that any of the syntax that follows is good
make 2>&1 >(LogMsg)
LogMsg
的能力吗? - chepnerLogMsg
只在make
完成后调用,而不是像一个假设的>(LogMsg)
一样实时调用。 - pmiguelpinto