summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Rettberg2021-01-13 14:38:11 +0100
committerSimon Rettberg2021-01-13 14:38:11 +0100
commitd78ee7fedb0cf7b5d582e69370b974a4294ca022 (patch)
tree4087a770638e29c7c203a5d4d7b08cf1bf30939f
parent[dev] More sanity checks, fallback to GPT if MBR yields nothing (diff)
downloadslx-tools-d78ee7fedb0cf7b5d582e69370b974a4294ca022.tar.gz
slx-tools-d78ee7fedb0cf7b5d582e69370b974a4294ca022.tar.xz
slx-tools-d78ee7fedb0cf7b5d582e69370b974a4294ca022.zip
[ini] New module
-rw-r--r--modules/ini.inc11
1 files changed, 11 insertions, 0 deletions
diff --git a/modules/ini.inc b/modules/ini.inc
new file mode 100644
index 0000000..c4a098c
--- /dev/null
+++ b/modules/ini.inc
@@ -0,0 +1,11 @@
+# Get specific value from ini file
+# ini_get <file> <section> <key>
+ini_get () {
+ awk -v section="^\\\\s*\\\\[$2\\\\]" -v key="^\\\\s*$3\\\\s*=\\\\s*" '{if ($0 ~ section) {ins=1} else if ($0 ~ "^\\s*\\[") {ins=0} else if (ins && $0 ~ key) {gsub(key, ""); print; exit 0} }' "$1"
+}
+
+# List all sections in ini file
+# ini_sections <file>
+ini_sections () {
+ awk '{if (match($0, "^\\s*\\[([^\\]]*)\\]", a)) {print a[1]}}' "$1"
+}