我需要帮助将系统命令的输出(stdin和stdout)发送到bash函数,同时仍接受来自参数的输入。就像下面的例子。有人能把我指向正确的道路吗?将stdout和stderr重定向到函数
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'用命令行参数的能力吗? – chepner 2012-08-10 16:42:19