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]}" "$@")
22
22
# $USER may be overwritten; if run command by `sudo -u`, may is not `root`.
23
23
# more info see https://www.baeldung.com/linux/get-current-user
24
24
#
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!
26
26
# more info see https://github.com/koalaman/shellcheck/wiki/SC2155
27
27
WHOAMI=$( whoami)
28
- readonly WHOAMI
28
+ UNAME=$( uname)
29
+ readonly WHOAMI UNAME
29
30
30
31
# ###############################################################################
31
32
# util functions
@@ -196,10 +197,10 @@ progVersion() {
196
197
}
197
198
198
199
# ###############################################################################
199
- # Check os support
200
+ # check os support
200
201
# ###############################################################################
201
202
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!"
203
204
204
205
# ###############################################################################
205
206
# parse options
@@ -565,10 +566,6 @@ printStackOfThreads() {
565
566
done
566
567
}
567
568
568
- # ###############################################################################
569
- # Main
570
- # ###############################################################################
571
-
572
569
main () {
573
570
local update_round_num
574
571
# 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
50
50
# ###############################################################################
51
51
52
52
# 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
54
55
55
56
# shellcheck disable=SC2086
56
57
netstat -tna ${option_for_mac:- } | awk ' NR > 2 {
You can’t perform that action at this time.
0 commit comments