jw-pkg/scripts/ini-tools.sh
Jan Lindemann 77c746571a
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m23s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 4m30s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 4m2s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m6s
CI / Packaging test (push) Successful in 0s
scripts: Fix shellcheck errors

Fix shellcheck SC2068 (unquoted array expansions), SC2145 (mixed string/array arguments), SC2328 (redirection in command substitution), SC2173 (untrapable signals), and SC2148 (missing shebang) errors across 14 script files.

Also configure scripts/Makefile with --severity=error so that only errors (not warnings or notes) cause check failures. To be tightened by follow-up commits.

Assisted-by: unsloth/Qwen3.6-35B-A3B-GGUF:IQ4_NL and pi.dev
Signed-off-by: Jan Lindemann <jan@janware.com>
2026-06-29 17:52:24 +02:00

57 lines
872 B
Bash

#!/bin/sh
ini_section()
{
local inifile="$1"
local sec="$2"
cat "$inifile" |
cut -d\# -f1 |
tr -s '\n' '\n' |
sed -n "/^ *\[$sec\]/,/^ *\[/ p" |
grep -v '^ *\[' |
sed '/^ *$/ d'
}
ini_value()
{
local inifile="$1"
local path="$2"
local sec=`echo "$path" | sed 's/\.[^.]\+$//'`
local key=`echo "$path" | sed 's/.*\.//'`
# echo "path=>$path<"
# echo "sec=>$sec<"
# echo "key=>$key<"
if [ "$key" = "$path" ]; then
ini_section "$inifile" "$path"
return 0
fi
ini_section "$inifile" "$sec" | sed "
/^ *$key *=/ !d
s/^ *$key *= *//
s/ *$//
/^ *$/ d
"
}
ini_has_section()
{
local inifile="$1"
local sec="$2"
grep -q "^ *\[$sec\]" $inifile || return 1
}
ini_has_value()
{
ini_value "$@" | grep -q .
}
ini_escape()
{
cat | sed '
s/\$/\\$/g
s/`/\\\`/g
'
}