File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -22,10 +22,11 @@ readonly -a COMMAND_LINE=("${BASH_SOURCE[0]}" "$@")
2222# $USER may be overwritten; if run command by `sudo -u`, may is not `root`.
2323# more info see https://www.baeldung.com/linux/get-current-user
2424#
25- # DO NOT declare and assign var WHOAMI (as readonly) in ONE line!
25+ # DO NOT declare and assign var(as readonly) in ONE line!
2626# more info see https://github.com/koalaman/shellcheck/wiki/SC2155
2727WHOAMI=$( whoami)
28- readonly WHOAMI
28+ UNAME=$( uname)
29+ readonly WHOAMI UNAME
2930
3031# ###############################################################################
3132# util functions
@@ -196,10 +197,10 @@ progVersion() {
196197}
197198
198199# ###############################################################################
199- # Check os support
200+ # check os support
200201# ###############################################################################
201202
202- uname | grep ' ^ Linux' -q || die " $PROG only support Linux, not support $( uname ) yet!"
203+ [[ $UNAME = Linux* ]] || die " $PROG only support Linux, not support $UNAME yet!"
203204
204205# ###############################################################################
205206# parse options
@@ -565,10 +566,6 @@ printStackOfThreads() {
565566 done
566567}
567568
568- # ###############################################################################
569- # Main
570- # ###############################################################################
571-
572569main () {
573570 local update_round_num
574571 # if update_count <= 0, infinite loop till user interrupted (eg: CTRL+C)
Original file line number Diff line number Diff line change @@ -50,7 +50,8 @@ unset args idx
5050# ###############################################################################
5151
5252# On MacOS, netstat need to using -p tcp to get only tcp output.
53- uname | grep Darwin -q && option_for_mac=-ptcp
53+ UNAME=$( uname)
54+ [[ $UNAME = Darwin* ]] && option_for_mac=-ptcp
5455
5556# shellcheck disable=SC2086
5657netstat -tna ${option_for_mac:- } | awk ' NR > 2 {
You can’t perform that action at this time.
0 commit comments