Skip to content

Commit 7d3cf1a

Browse files
committed
fix wrong USER var when run by sudo -u
1 parent 3894d2e commit 7d3cf1a

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

show-busy-java-threads.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
readonly PROG=`basename $0`
1212
readonly -a COMMAND_LINE=("$0" "$@")
1313

14+
# Get corrent current user name via whoami command
15+
# See get https://www.lifewire.com/current-linux-user-whoami-command-3867579
16+
# Because if use `sudo -u` to run command, env var $USER is not rewrited/correct, just inherited from outside!
17+
readonly USER="`whoami`"
18+
1419
usage() {
1520
local out
1621
[ -n "$1" -a "$1" != 0 ] && out=/dev/stderr || out=/dev/stdout

0 commit comments

Comments
 (0)