mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-04-18 16:32:17 +00:00
style: formatting cleanup in api.func and core.func
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user