【问题标题】:Getting cppcheck to work well with pipes让 cppcheck 与管道一起正常工作
【发布时间】:2015-01-24 15:25:41
【问题描述】:

我想在 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

【问题讨论】:

    标签: awk cppcheck


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-07-19
      • 2015-06-11
      • 1970-01-01
      • 2019-04-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多