让cppcheck与管道配合良好

时间:2015-01-24 15:25:41

标签: awk cppcheck

我想在cppcheck的输出上使用awk - 但是看起来cppcheck在这个衬里的末尾没有输出到awk将打印件放到屏幕上。有没有办法让cppcheck的输出只进入管道awk所以我可以过滤它?

git status -s | awk '(($1 ~ /M/) || ($1 ~ /A/)) { print $2 }' | xargs cppcheck -j 2 --enable=warning,performance | awk '/error/ { print $1 }'

这是我的输出

[silly.cpp:9]: (warning) %d in format string (no. 1) requires 'int' but the argument type is 'char *'.
[silly.cpp:7]: (error) Buffer is accessed out of bounds: buf

1 个答案:

答案 0 :(得分:2)

可能输出到stderr而不是stdout。尝试:

cppcheck ... 2>&1 | awk ...