Trim white space and fix non tab indents

pull/111/head
aristocratos 2020-05-07 19:46:53 +02:00
parent fbe585f59a
commit 7e1ab42cf9
1 changed files with 32 additions and 32 deletions

52
bashtop
View File

@ -219,8 +219,8 @@ else
get_ms() { #? Set given variable to current epoch millisecond with date command through background fifo get_ms() { #? Set given variable to current epoch millisecond with date command through background fifo
local -n ms_out=$1 local -n ms_out=$1
echo now >&5 && echo now >&5 &&
read -u 6 ms_out read -u 6 ms_out
} }
else else
@ -646,15 +646,15 @@ sort_array_int() { #? Copy and sort an array of integers from largest to smalles
local array=("${in_arr[@]}") local array=("${in_arr[@]}")
#* Start sorting #* Start sorting
for ((start_n=0;start_n<=${#array[@]}-1;++start_n)); do for ((start_n=0;start_n<=${#array[@]}-1;++start_n)); do
for ((search_n=start_n+1;search_n<=${#array[@]}-1;++search_n)); do for ((search_n=start_n+1;search_n<=${#array[@]}-1;++search_n)); do
if ((array[start_n]<array[search_n])); then if ((array[start_n]<array[search_n])); then
tmp_array=${array[start_n]} tmp_array=${array[start_n]}
array[start_n]=${array[search_n]} array[start_n]=${array[search_n]}
array[search_n]=$tmp_array array[search_n]=$tmp_array
fi fi
done done
done done
#* Write the sorted array to output array #* Write the sorted array to output array
out_arr=("${array[@]}") out_arr=("${array[@]}")
@ -673,24 +673,24 @@ spaces() { #? Prints back spaces, usage: spaces "number of spaces"
} }
is_int() { #? Check if value(s) is integer is_int() { #? Check if value(s) is integer
local param local param
for param; do for param; do
if [[ ! $param =~ ^[\-]?[0-9]+$ ]]; then return 1; fi if [[ ! $param =~ ^[\-]?[0-9]+$ ]]; then return 1; fi
done done
} }
is_float() { #? Check if value(s) is floating point is_float() { #? Check if value(s) is floating point
local param local param
for param; do for param; do
if [[ ! $param =~ ^[\-]?[0-9]*[,.][0-9]+$ ]]; then return 1; fi if [[ ! $param =~ ^[\-]?[0-9]*[,.][0-9]+$ ]]; then return 1; fi
done done
} }
is_hex() { #? Check if value(s) is hexadecimal is_hex() { #? Check if value(s) is hexadecimal
local param local param
for param; do for param; do
if [[ ! ${param//#/} =~ ^[0-9a-fA-F]*$ ]]; then return 1; fi if [[ ! ${param//#/} =~ ^[0-9a-fA-F]*$ ]]; then return 1; fi
done done
} }
floating_humanizer() { #? Convert integer to floating point and scale up in steps of 1024 to highest positive unit floating_humanizer() { #? Convert integer to floating point and scale up in steps of 1024 to highest positive unit
@ -868,9 +868,9 @@ get_themes() {
} }
cur_pos() { #? Get cursor postion, argument "line" prints current line, argument "col" prints current column, no argument prints both in format "line column" cur_pos() { #? Get cursor postion, argument "line" prints current line, argument "col" prints current column, no argument prints both in format "line column"
local line col local line col
IFS=';' read -sdR -p $'\E[6n' line col IFS=';' read -sdR -p $'\E[6n' line col
if [[ -z $1 || $1 == "line" ]]; then echo -n "${line#*[}${1:-" "}"; fi if [[ -z $1 || $1 == "line" ]]; then echo -n "${line#*[}${1:-" "}"; fi
if [[ -z $1 || $1 == "col" ]]; then echo -n "$col"; fi if [[ -z $1 || $1 == "col" ]]; then echo -n "$col"; fi
} }