Make some minor cosmetic improvements
This commit is contained in:
parent
474ba22817
commit
a39c3ce06a
31
rowbot
31
rowbot
|
@ -137,6 +137,17 @@ run_callbacks() {
|
||||||
return "$status"
|
return "$status"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prints() {
|
||||||
|
# This is a wrapper around printf so the format string isn't known ahead of
|
||||||
|
# time.
|
||||||
|
# shellcheck disable=SC2059
|
||||||
|
printf "$@"
|
||||||
|
|
||||||
|
if [[ -t 1 ]]; then
|
||||||
|
printf \\n
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# The variables are checked dynamically
|
# The variables are checked dynamically
|
||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
seconds() {
|
seconds() {
|
||||||
|
@ -160,11 +171,7 @@ seconds() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
printf -- %s "$time"
|
prints %s "$time"
|
||||||
|
|
||||||
if [[ -t 1 ]]; then
|
|
||||||
printf \\n
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
url() {
|
url() {
|
||||||
|
@ -174,11 +181,7 @@ url() {
|
||||||
printf ircs://
|
printf ircs://
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf %s:%s "${config[server]}" "${config[port]}"
|
prints %s:%s "${config[server]}" "${config[port]}"
|
||||||
|
|
||||||
if [[ -t 1 ]]; then
|
|
||||||
printf \\n
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
b64_encode() {
|
b64_encode() {
|
||||||
|
@ -194,19 +197,19 @@ b64_encode() {
|
||||||
(( table_idxs[1] = (((numerics[0] & 0x03) << 6) | (numerics[1] & 0xF0) >> 2) >> 2 ))
|
(( table_idxs[1] = (((numerics[0] & 0x03) << 6) | (numerics[1] & 0xF0) >> 2) >> 2 ))
|
||||||
(( table_idxs[2] = (((numerics[1] & 0x0F) << 4) | (numerics[2] & 0xC0) >> 4) >> 2 ))
|
(( table_idxs[2] = (((numerics[1] & 0x0F) << 4) | (numerics[2] & 0xC0) >> 4) >> 2 ))
|
||||||
(( table_idxs[3] = numerics[2] & 0x3F ))
|
(( table_idxs[3] = numerics[2] & 0x3F ))
|
||||||
|
|
||||||
for table_idx in "${table_idxs[@]}"; do
|
for table_idx in "${table_idxs[@]}"; do
|
||||||
encoded+=${table[$table_idx]}
|
encoded+=${table[$table_idx]}
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
if (( ${#1} % 3 == 1 )); then
|
if (( ${#1} % 3 == 1 )); then
|
||||||
encoded=${encoded::-2}==
|
encoded=${encoded::-2}==
|
||||||
elif (( ${#1} % 3 == 2 )); then
|
elif (( ${#1} % 3 == 2 )); then
|
||||||
encoded=${encoded::-1}=
|
encoded=${encoded::-1}=
|
||||||
fi
|
fi
|
||||||
printf %s "$encoded"
|
|
||||||
if [[ -t 1 ]]; then
|
prints %s "$encoded"
|
||||||
printf \\n
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
###
|
###
|
||||||
|
|
Loading…
Reference in New Issue