Skip to content

Commit

Permalink
use if instead &&/||
Browse files Browse the repository at this point in the history
avoid exit logic bug when "if clause" fail
  • Loading branch information
oldratlee committed May 24, 2018
1 parent 5a50de8 commit 3de60d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions c
Original file line number Diff line number Diff line change
Expand Up @@ -97,5 +97,8 @@ teeAndCopy() {
) > $out
}

[ ${#args[@]} -eq 0 ] && teeAndCopy ||
"${args[@]}" | teeAndCopy
if [ ${#args[@]} -eq 0 ]; then
teeAndCopy
else
"${args[@]}" | teeAndCopy
fi
2 changes: 1 addition & 1 deletion docs/java.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
用于快速排查`Java``CPU`性能问题(`top us`值过高),自动查出运行的`Java`进程中消耗`CPU`多的线程,并打印出其线程栈,从而确定导致性能问题的方法调用。
目前只支持`Linux`。原因是`Mac``Windows``ps`命令不支持列出线程线程,更多信息参见[#33](https://github.com/oldratlee/useful-scripts/issues/33),欢迎提供解法。

PS,如何操作可以参见[@bluedavy](http://weibo.com/bluedavy)[《分布式Java应用》](https://book.douban.com/subject/4848587/)的【5.1.1 cpu消耗分析】一节,说得很详细:
PS,如何操作可以参见[@bluedavy](http://weibo.com/bluedavy)[《分布式Java应用》](https://book.douban.com/subject/4848587/)的【5.1.1 `CPU`消耗分析】一节,说得很详细:

1. `top`命令找出有问题`Java`进程及线程`id`
1. 开启线程显示模式(`top -H`,或是打开`top`后按`H`
Expand Down

0 comments on commit 3de60d1

Please sign in to comment.