style: formatting cleanup in api.func and core.func

This commit is contained in:
MickLesk
2026-03-23 20:46:34 +01:00
parent 2008b1b458
commit be52f8e223
2 changed files with 11 additions and 8 deletions

View File

@@ -348,10 +348,10 @@ explain_exit_code() {
json_escape() { json_escape() {
# Escape a string for safe JSON embedding using awk (handles any input size). # Escape a string for safe JSON embedding using awk (handles any input size).
# Pipeline: strip ANSI → remove control chars → escape \ " TAB → join lines with \n # Pipeline: strip ANSI → remove control chars → escape \ " TAB → join lines with \n
printf '%s' "$1" \ printf '%s' "$1" |
| sed 's/\x1b\[[0-9;]*[a-zA-Z]//g' \ sed 's/\x1b\[[0-9;]*[a-zA-Z]//g' |
| tr -d '\000-\010\013\014\016-\037\177\r' \ tr -d '\000-\010\013\014\016-\037\177\r' |
| awk ' awk '
BEGIN { ORS = "" } BEGIN { ORS = "" }
{ {
gsub(/\\/, "\\\\") # backslash → \\ gsub(/\\/, "\\\\") # backslash → \\
@@ -1333,10 +1333,10 @@ post_addon_to_api() {
while IFS='=' read -r _k _v; do while IFS='=' read -r _k _v; do
_v="${_v//\"/}" _v="${_v//\"/}"
case "$_k" in case "$_k" in
ID) os_type="$_v" ;; ID) os_type="$_v" ;;
VERSION_ID) os_version="$_v" ;; VERSION_ID) os_version="$_v" ;;
esac esac
done < /etc/os-release done </etc/os-release
fi fi
local JSON_PAYLOAD local JSON_PAYLOAD

View File

@@ -1688,7 +1688,10 @@ function get_lxc_ip() {
local -a _ips6 local -a _ips6
read -ra _ips6 <<<"$(hostname -I 2>/dev/null)" read -ra _ips6 <<<"$(hostname -I 2>/dev/null)"
for ip in "${_ips6[@]}"; do for ip in "${_ips6[@]}"; do
[[ "$ip" == *:* ]] && { echo "$ip"; return 0; } [[ "$ip" == *:* ]] && {
echo "$ip"
return 0
}
done done
fi fi