More explanation
Getty Ritter
10 years ago
| 46 | 46 | have this property in practice. |
| 47 | 47 | |
| 48 | 48 | As a pleasant but unintended side effect, an executable bash file that |
| 49 |
does nothing but define environment variables is |
|
| 49 | does nothing but define environment variables is often trivially an NDBL | |
| 50 | 50 | file. |
| 51 | 51 | |
| 52 | 52 | Structure of an NDBL Document |
| 87 | 87 | Examples With Explanation |
| 88 | 88 | ------------------------- |
| 89 | 89 | |
| 90 | In the examples below, I will use `{ key: value }` as shorthand to represent a | |
| 91 | multimap. | |
| 90 | In the examples below, I will use `[ key: value ]` as shorthand to represent an | |
| 91 | ordered sequence of key-value pairs. | |
| 92 | 92 | |
| 93 | 93 | host=machine1 |
| 94 | 94 | host=machine2 |
| 95 | 95 | |
| 96 | 96 | This parses to the following structure: |
| 97 | 97 | |
| 98 |
[ |
|
| 98 | [[ "host": "machine1" ], [ "host": "machine2" ]] | |
| 99 | 99 | |
| 100 | 100 | Adding indentation merges the two multisets, as the second line is now |
| 101 | 101 | considered a 'cotinuation' of the first group. |
| 105 | 105 | |
| 106 | 106 | This becomes |
| 107 | 107 | |
| 108 |
[ |
|
| 108 | [[ "host": "machine1", "host": "machine2" ]] | |
| 109 | 109 | |
| 110 | 110 | A third non-indented line will then start a new group: |
| 111 | 111 | |
| 115 | 115 | |
| 116 | 116 | This becomes |
| 117 | 117 | |
| 118 |
[ |
|
| 118 | [ [ "host": "machine1" | |
| 119 | , "host": "machine2" | |
| 120 | ] | |
| 121 | , [ "host": "machine3" ] | |
| 122 | ] | |
| 119 | 123 | |
| 120 |
Empty values are permitted, and |
|
| 124 | Empty values are permitted, and are idiomatically used as a 'header' for a group | |
| 125 | of configuration options: | |
| 121 | 126 | |
| 122 | 127 | database= |
| 123 | 128 | file=file1.txt |
| 126 | 131 | |
| 127 | 132 | This becomes |
| 128 | 133 | |
| 129 |
[ |
|
| 134 | [["database": "", "file": "file1.txt", "file": "file2.txt", "file": "file3.txt"]] | |
| 130 | 135 | |
| 131 | 136 | Comments are allowed but must come after a whitespace character, which |
| 132 | 137 | means that the following document contains no comments: |
| 135 | 140 | |
| 136 | 141 | This becomes |
| 137 | 142 | |
| 138 |
[ |
|
| 143 | [["key": "value#hello"]] | |
| 139 | 144 | |
| 140 | 145 | But this document does contain a comment: |
| 141 | 146 | |
| 143 | 148 | |
| 144 | 149 | This becomes |
| 145 | 150 | |
| 146 |
[ |
|
| 151 | [["key": "value"]] | |
| 147 | 152 | |
| 148 | 153 | Comments can begin a line, as well. |
| 149 | 154 | |
| 154 | 159 | port=22 |
| 155 | 160 | user=abu-al-walid |
| 156 | 161 | nicename="H-G Remote Server" |
| 162 | ||
| 163 | This document corresponds to | |
| 164 | ||
| 165 | [ [ "host": "hg-remote" | |
| 166 | , "portforwarding": "" | |
| 167 | , "hostname": "hunter-gratzner.example.com" | |
| 168 | , "port": "22" | |
| 169 | , "user": "abu-al-walid" | |
| 170 | , "nicename": "H-G Remote Server" | |
| 171 | ] | |
| 172 | ] | |
| 157 | 173 | |
| 158 | 174 | NDBL does not provide arbitrarily-nested hierarchical strutures, |
| 159 | 175 | a list type, a numeric type, a boolean type, or other niceties. This does not |