Skip to content

Commit 2234c09

Browse files
committed
Declare and assign separately to avoid masking return values
1 parent 17975cd commit 2234c09

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

tools/ci/circle/system_metrics

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ on_error() {
4242
# memory_used_in_MB,total_memory_in_MB,percent_used
4343
#
4444
memory_usage() {
45-
local mem=$(free -m | awk 'NR==2 {printf "%sMB,%sMB,%.2f%%)", $3, $2, $3*100/$2}')
45+
local mem
46+
mem=$(free -m | awk 'NR==2 {printf "%sMB,%sMB,%.2f%%)", $3, $2, $3*100/$2}')
4647
echo "${mem}"
4748
}
4849

@@ -53,13 +54,15 @@ memory_usage() {
5354
# disk_used_in_GB,total_disk_space_in_GB,percent_used
5455
#
5556
disk_usage() {
56-
local disk=$(df -h | awk '$NF=="/" {printf "%dGB,%dGB,%s", $3, $2, $5}')
57+
local disk
58+
disk=$(df -h | awk '$NF=="/" {printf "%dGB,%dGB,%s", $3, $2, $5}')
5759
echo "${disk}"
5860
}
5961

6062
# Prints the system load average.
6163
load_avg() {
62-
local load=$(top -bn1 | grep load | awk '{printf "%.2f", $(NF-2)}')
64+
local load
65+
load=$(top -bn1 | grep load | awk '{printf "%.2f", $(NF-2)}')
6366
echo "${load}"
6467
}
6568

0 commit comments

Comments
 (0)