You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+24-20Lines changed: 24 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,10 +17,27 @@ Treats a no-section (any `keyword=keyvalue` before a `[section]`) as a '`[Defaul
17
17
18
18
Also correctly finds the last keyvalue of the desired section/keyword before extracting its keyvalue, despite its multiply-defined/multiple-reused interspersed/alternating section blocks.
19
19
20
+
Details
21
+
=======
22
+
23
+
File format: .INI
24
+
Supported version: 1.4 (2009)
25
+
26
+
Features
27
+
----
28
+
Currently supported features are:
29
+
30
+
* loads all settings into a multi-line bash string (no need for variable array)
31
+
* Treats no-section as '`[Default]`'; reads both sections together as Default.
32
+
* Check the section name and keyword name for valid character set.
33
+
* Nested quotes also works alongside with inline comment (except for '//' inline comment support)
34
+
* Supports and ignores inline comment using semicolon '`;`', hashmark '`#`'; But the double-slash '`//`' regex has been properly defined but not yet integrated as `bash` yet. See [Issue 1](https://github.com/egberts/bash-ini-file/issues/1).
35
+
* Some 30,000 keyvalue lookups per second, no it is more like 20/second; well, like performance really matters here anyway.
36
+
20
37
HOW I DID THIS
21
38
==============
22
39
23
-
The secret sauce is to convert the entire INI file into a parsable syntax format with one `awk`:
40
+
The secret sauce is to convert the entire INI file into a parsable syntax format just with this one `awk` programming:
24
41
25
42
```awk
26
43
/^\[.*\]$/{obj=0ドル}/=/{print obj 0ドル}'
@@ -55,12 +72,14 @@ get turned into this:
55
72
[Default]FirstDefaultKeyword=1
56
73
```
57
74
58
-
Parsable AWK/SED/GREP Galore!
75
+
Note: Notice that we treated the 'no-section' as `[Default]`?
76
+
77
+
Parsable Galore!
59
78
=======
60
-
With a common `[section]keyword=keyvalue`, it now becomes possible to work with INI line-records in a faster manner using `sed`, `awk` and `tail`.
79
+
With the usage of a common `[section]keyword=keyvalue` format, it now becomes easily possible to work with INI line-records in a faster manner using `sed`, `awk` and `tail` or even `grep`.
61
80
62
81
63
-
How To Use bash-ini-parser
82
+
APIs, APIs, Lots of API; well, just a few.
64
83
====
65
84
Simply source the lone script file: `bash-ini-parser.sh`
66
85
and start calling APIs such as:
@@ -78,21 +97,6 @@ and start calling APIs such as:
78
97
|`ini_keyvalue_get`|`-`| multi-line | Get the key value based on given section name and keyword name (most useful with `systemd`, `NetworkManager`. |
79
98
|`ini_keyvalue_get_last`|`-`| string | Get the LAST key value encountered given a section name and a keyword name. (most useful if only interested by matched keyword for the last `keyword=keyvalue` to obtain its overridden keyvalue. |
80
99
81
-
Details
82
-
=======
83
-
84
-
File format: .INI
85
-
Supported version: 1.4 (2009)
86
-
87
-
Features:
88
-
89
-
* Supports and ignores inline comment using semicolon '`;`', hashmark '`#`'; But the double-slash '`//`' regex has been properly defined but not yet integrated as `bash` yet. See [Issue 1](https://github.com/egberts/bash-ini-file/issues/1).
90
-
* loads all settings into bash string (no variable array)
91
-
* Treats no-section as '`[Default]`'; reads both sections together as one.
92
-
* Check the section name and keyword name for valid character set.
93
-
* Nested quotes also works alongside with inline comment (except for '//' inline comment support)
94
-
* 30,000 keyvalue lookup per second. (well, like performance really matters here anyway)
95
-
96
100
Demo
97
101
====
98
102
A nice bash script can be either my `example-usage.sh` script or below:
@@ -133,7 +137,7 @@ Unit Test
133
137
=========
134
138
The accompanied `tests` subdirectory performs the comprehensive unit testing, in case you have decided to tweaked it to your normative scenario; hopefully, this will find any errors of yours.
135
139
136
-
To exercise the test, your modified `bash-ini-parser.sh must reside above the `tests` directory as all the unit tests will perform:
140
+
To exercise a specific unit test, your modified `bash-ini-parser.sh` must reside above the `tests` directory as all the unit tests will perform and find your modified script 'above':
0 commit comments