让 cppcheck 与管道一起工作
Getting cppcheck to work well with pipes
我想在 cppcheck 的输出上使用 awk - 但似乎 cppcheck 没有输出到 awk 在这个 liner 的末尾将打印件打印到屏幕上。有什么方法可以让 cppcheck 的输出只进入到 awk 的管道,以便我可以过滤它?
git status -s | awk '(( ~ /M/) || ( ~ /A/)) { print }' | xargs cppcheck -j 2 --enable=warning,performance | awk '/error/ { print }'
这是我的输出
[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
它可能输出到 stderr 而不是 stdout。尝试:
cppcheck ... 2>&1 | awk ...
我想在 cppcheck 的输出上使用 awk - 但似乎 cppcheck 没有输出到 awk 在这个 liner 的末尾将打印件打印到屏幕上。有什么方法可以让 cppcheck 的输出只进入到 awk 的管道,以便我可以过滤它?
git status -s | awk '(( ~ /M/) || ( ~ /A/)) { print }' | xargs cppcheck -j 2 --enable=warning,performance | awk '/error/ { print }'
这是我的输出
[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
它可能输出到 stderr 而不是 stdout。尝试:
cppcheck ... 2>&1 | awk ...