mirror of
https://github.com/black7375/Firefox-UI-Fix.git
synced 2026-01-30 04:10:32 -08:00
Add: Installer - INI file functions
This commit is contained in:
parent
4e6b3107a2
commit
4d9eb169f7
1 changed files with 48 additions and 0 deletions
48
install.sh
48
install.sh
|
|
@ -166,6 +166,54 @@ autorestore() {
|
|||
fi
|
||||
}
|
||||
|
||||
#== INI File ================================================================
|
||||
get_ini_section() {
|
||||
local filePath="$1"
|
||||
echo $(grep -E "^\[" "${filePath}" |sed -e "s/^\[//g" -e "s/\]$//g")
|
||||
}
|
||||
get_ini_value() {
|
||||
local filePath="$1"
|
||||
local key="$2"
|
||||
local section="$3"
|
||||
|
||||
if [ "${section}" == "" ]; then
|
||||
echo $(grep -E "^${key}" "${filePath}" | cut -f 2 -d"=")
|
||||
else
|
||||
local sectionStart=""
|
||||
for line in $(cat "${filePath}"); do
|
||||
if [[ "${sectionStart}" == "true" && "${line}" == "["* ]]; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [ "${line}" == "[${section}]" ]; then
|
||||
sectionStart="true"
|
||||
fi
|
||||
|
||||
if [ "${sectionStart}" == "true" ]; then
|
||||
local output=$(echo "${line}" | grep -E "^${key}" | cut -f 2 -d"=" )
|
||||
if [ "${output}" != "" ]; then
|
||||
echo "${output}"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
set_ini_section() {
|
||||
local section="$1"
|
||||
echo "[${section}]\n"
|
||||
}
|
||||
set_ini_value() {
|
||||
local key="$1"
|
||||
local value="$2"
|
||||
|
||||
if [ "${value}" == "" ]; then
|
||||
echo ""
|
||||
else
|
||||
echo "${key}=${value}\n"
|
||||
fi
|
||||
}
|
||||
|
||||
#== Multiselect ================================================================
|
||||
# https://stackoverflow.com/questions/45382472/bash-select-multiple-answers-at-once/54261882
|
||||
multiselect() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue