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"
|
||||
}
|
||||
|
||||
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
|
||||
# shellcheck disable=SC2034
|
||||
seconds() {
|
||||
|
@ -160,11 +171,7 @@ seconds() {
|
|||
fi
|
||||
done
|
||||
|
||||
printf -- %s "$time"
|
||||
|
||||
if [[ -t 1 ]]; then
|
||||
printf \\n
|
||||
fi
|
||||
prints %s "$time"
|
||||
}
|
||||
|
||||
url() {
|
||||
|
@ -174,11 +181,7 @@ url() {
|
|||
printf ircs://
|
||||
fi
|
||||
|
||||
printf %s:%s "${config[server]}" "${config[port]}"
|
||||
|
||||
if [[ -t 1 ]]; then
|
||||
printf \\n
|
||||
fi
|
||||
prints %s:%s "${config[server]}" "${config[port]}"
|
||||
}
|
||||
|
||||
b64_encode() {
|
||||
|
@ -194,19 +197,19 @@ b64_encode() {
|
|||
(( 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[3] = numerics[2] & 0x3F ))
|
||||
|
||||
for table_idx in "${table_idxs[@]}"; do
|
||||
encoded+=${table[$table_idx]}
|
||||
done
|
||||
done
|
||||
|
||||
if (( ${#1} % 3 == 1 )); then
|
||||
encoded=${encoded::-2}==
|
||||
elif (( ${#1} % 3 == 2 )); then
|
||||
encoded=${encoded::-1}=
|
||||
fi
|
||||
printf %s "$encoded"
|
||||
if [[ -t 1 ]]; then
|
||||
printf \\n
|
||||
fi
|
||||
|
||||
prints %s "$encoded"
|
||||
}
|
||||
|
||||
###
|
||||
|
|
Loading…
Reference in New Issue