diff --git a/bashtop b/bashtop index 2c8378c..c78797f 100755 --- a/bashtop +++ b/bashtop @@ -513,7 +513,7 @@ traperr() { #? Function for reporting error line numbers fi if ((len>100)); then unset 'trace_array[@]'; fi trace_array+=("$err") - echo "$(printf "%(%X)T") ERROR: On line $err $trap_muted" >> "${config_dir}/error.log" + printf "%(%X)T ERROR: On line %s %s\n" -1 "$err" "$trap_muted" >> "${config_dir}/error.log" } @@ -1472,7 +1472,7 @@ collect_cpu_temps() { #? Collect cpu temperatures local -a ccd_array core_array #* Fetch output from "sensors" command to a variable - sens_var="$(sensors)" + read -rd '' sens_var < <(sensors) ||true #* Get CPU package temp for intel cpus if get_value -v 'cpu[temp_0]' -sv "sens_var" -k "Package*:" -mk 1 || get_value -v 'cpu[temp_0]' -sv "sens_var" -k "Core 0:" -mk 1; then @@ -1529,7 +1529,7 @@ collect_cpu_temps() { #? Collect cpu temperatures #* Get CPU package temp for Rapberry Pi cpus elif command -v vcgencmd >/dev/null 2>&1; then - cpu[temp_0]="$(vcgencmd measure_temp 2>/dev/null ||true)" + read -r cpu[temp_0] < <(vcgencmd measure_temp 2>/dev/null ||true) ||true if [[ -z ${cpu[temp_0]} ]]; then cpu[temp_0]="temp=0.0°C"; fi cpu[temp_0]="${cpu[temp_0]#temp=}" cpu[temp_unit]="°${cpu[temp_0]:(-1)}"; cpu[temp_0]=${cpu[temp_0]%.*}; if [[ ${cpu[temp_0]::1} == "+" ]]; then cpu[temp_0]=${cpu[temp_0]#+}; fi @@ -1568,7 +1568,7 @@ collect_mem() { #? Collect memory information from "/proc/meminfo" local -a mem_array swap_array available=("mem") #* Get memory and swap information from "/proc/meminfo" and calculate percentages - mem_info="$(5)); then proc[detailed_mem_count]=0 @@ -1831,7 +1836,8 @@ collect_processes() { #? Collect process information and calculate accurate cpu elif ((proc[detailed_mem_int]>100)); then proc[detailed_mem_int]=$((proc[detailed_mem_int]/2)) elif ((proc[detailed_mem_int]<50)); then proc[detailed_mem_int]=$((proc[detailed_mem_int]*2)); fi unset 'proc[detailed_mem_string]' - floating_humanizer -v proc[detailed_mem_string] -B -s 1 "$(ps -o rss:1 --no-headers -p ${pid} || true)" + read -r mem_string < <(ps -o rss:1 --no-headers -p ${pid} || true) + floating_humanizer -v proc[detailed_mem_string] -B -s 1 $mem_string if [[ -z ${proc[detailed_mem_string]} ]]; then proc[detailed_mem_string]="? Byte"; fi fi @@ -1888,9 +1894,13 @@ collect_processes() { #? Collect process information and calculate accurate cpu if ((breaking==1)); then if [[ ${proc[detailed]} == "1" && -z ${proc[detailed_cpu]} ]] && ps ${proc[detailed_pid]} >/dev/null 2>&1; then readarray ${options} -O ${#proc_array[@]} proc_array < <(ps -o pid:${proc[pid_len]}=Pid:,comm:${format_cmd}=${tree:-Program:}${format_args},nlwp:3=Tr:,euser:6=User:,pmem=Mem%,pcpu:10=Cpu% --no-headers -p ${proc[detailed_pid]} || true) + ((++breaking)) else break fi + elif ((breaking==2)); then + unset 'proc_array[-1]' + break fi done