-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBASH.txt
More file actions
379 lines (314 loc) · 12.9 KB
/
Copy pathBASH.txt
File metadata and controls
379 lines (314 loc) · 12.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
REGEDITED BASH INTERACTIVE REFERENCE
This is plain text on purpose. It assumes you are sitting in an interactive Bash-like shell.
On Windows Git Bash or WSL, clip.exe is usually the simplest pipe-to-clipboard target.
The native Regedited clipboard route is better when available: ref-get ... --clip.
Core rule:
Canonical index openers are any line containing the exact lowercase byte phrase regedited open.
Nothing before or after that phrase is parsed. The following index: line is the identity.
Use index:<N> in commands. Human labels belong in string 1, 2, or 3.
Slot rules:
ref-* commands use 1-based slots:
index:5:string:1 through index:5:string:3
index:5:db:1 through index:5:db:9
index:5:zone:1 through index:5:zone:3
index:5:zonehex:1 through index:5:zonehex:3
Older section commands use 0-based slots:
set-str FILE SECTION 0 through 2
set-num FILE SECTION 0 through 8
clip FILE SECTION 0 through 2
clip-db FILE SECTION 0 through 8
grep FILE SECTION 0 through 2
zone-extract FILE SECTION 0 through 2
Recommended executable setup:
REG="./target/release/regedited.exe"
DOC="./regedited-playground.md"
# If regedited is on PATH instead:
# REG="regedited"
Create a sample canonical document:
cat > "$DOC" <<'EOF'
intro line outside any index
wdfkbsdfknwdbfkwbfkbwekfbwekfbregedited openwjfjbwdkjfbwjnfbwjnf
index: 5
0x0000009 : 0x000000A : 0x0000000 : 0x0000000 : 0x0000000 : 0x0000000
1 | 2 | 3 | 4 | 5 | 6 | 9 | 8 | 10
Index five label
Index five notes
Index five reference
---
index five zone line alpha
index five zone line beta
prefix-regedited open-suffix-is-ignored
index: 6
0x0000013 : 0x0000014 : 0x0000000 : 0x0000000 : 0x0000000 : 0x0000000
100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
Index six label
Index six notes
Index six reference
---
index six zone line alpha
index six zone line beta
garbage before regedited open garbage after
index: 38
0x000001D : 0x000001E : 0x0000000 : 0x0000000 : 0x0000000 : 0x0000000
11 | 22 | 33 | 44 | 55 | 66 | 77 | 88 | 99
Index thirty-eight label
Index thirty-eight notes
Index thirty-eight reference
---
index thirty-eight multiline value A
index thirty-eight multiline value B
regedited open
index: 869
0x0000027 : 0x0000028 : 0x0000000 : 0x0000000 : 0x0000000 : 0x0000000
1 | 2 | 3 | 4 | 5 | 300 | 7 | 8 | 9
Index eight-six-nine label
Index eight-six-nine notes
Index eight-six-nine reference
---
index eight-six-nine zone line alpha
index eight-six-nine zone line beta
EOF
Basic enumeration and inspection:
"$REG" list "$DOC"
"$REG" scan "$DOC"
"$REG" summary "$DOC"
"$REG" info "$DOC"
"$REG" state "$DOC"
"$REG" index-str-list "$DOC" 38
"$REG" db "$DOC" "index:38"
"$REG" hexline "$DOC" "index:38"
"$REG" content "$DOC" "index:38"
"$REG" zone-info "$DOC" "index:38" 0
"$REG" zone-info "$DOC" "index:38" 1
"$REG" zone-info "$DOC" "index:38" 2
Ref grammar accepted by ref-get, ref-set, ref-copy, ref-diff, and ref-bool:
index:38:string:1
index:38:str:1
index:38:db:7
index:38:num:7
index:38:number:7
index:38:dbline
index:38:hexline
index:38:hex-word-line
index:38:hex_word_line
index:38:ascii
index:38:ranges
index:38:zone:1
index:38:range:1
index:38:defined:1
index:38:zonehex:1
index:38:rangehex:1
index:38:defhex:1
index:38:definedhex:1
hex:0x000001D..0x000001E
hex:0x000001D : 0x000001E
hex:0x000001D,0x000001E
0x000001D
text:literal value
literal:literal value
Print specific values:
"$REG" ref-get "$DOC" "index:38:string:1"
"$REG" ref-get "$DOC" "index:38:string:2"
"$REG" ref-get "$DOC" "index:38:string:3"
"$REG" ref-get "$DOC" "index:38:db:7"
"$REG" ref-get "$DOC" "index:38:dbline"
"$REG" ref-get "$DOC" "index:38:hexline"
"$REG" ref-get "$DOC" "index:38:zonehex:1"
"$REG" ref-get "$DOC" "index:38:zone:1"
"$REG" ref-get "$DOC" "hex:0x000001D..0x000001E"
"$REG" ref-get "$DOC" "hex:0x000001D : 0x000001E"
"$REG" ref-get "$DOC" "hex:0x000001D,0x000001E"
"$REG" ref-get "$DOC" "0x000001D"
Clipboard routes:
# Best native route: ref-get copies the resolved value directly.
"$REG" ref-get "$DOC" "index:38:string:1" --clip
"$REG" ref-get "$DOC" "index:38:dbline" --clip
"$REG" ref-get "$DOC" "index:38:hexline" --clip
"$REG" ref-get "$DOC" "index:38:zonehex:1" --clip
"$REG" ref-get "$DOC" "index:38:zone:1" --clip
"$REG" ref-get "$DOC" "hex:0x000001D..0x000001E" --clip
"$REG" ref-get "$DOC" "0x000001D" --clip
# Pipe to Windows clipboard from Bash / Git Bash / WSL.
"$REG" ref-get "$DOC" "index:38:zone:1" | clip.exe
"$REG" ref-get "$DOC" "index:38:zonehex:1" | clip.exe
"$REG" ref-get "$DOC" "hex:0x000001D..0x000001E" | clip.exe
"$REG" hex-extract "$DOC" 0x000001D 0x000001E | clip.exe
# Linux desktop alternatives if not on Windows.
"$REG" ref-get "$DOC" "index:38:zone:1" | wl-copy
"$REG" ref-get "$DOC" "index:38:zone:1" | xclip -selection clipboard
# Legacy clipboard commands. These use section keys and zero-based slots.
"$REG" clip "$DOC" "index:38" 0
"$REG" clip-zone "$DOC" "index:38" 0
"$REG" clip-db "$DOC" "index:38" 6
"$REG" clip-dbline "$DOC" "index:38"
"$REG" clip-hexline "$DOC" "index:38"
# Generate a hex-word pair from normal line numbers and copy that pair.
# This copies the text 0x000001D : 0x000001E, not the content at those lines.
"$REG" clip-hexword 29 30 --zone-type markdown
"$REG" clip-hexword 29 30 --zone-type code
"$REG" clip-hexword 29 30 --zone-type media
"$REG" clip-hexword 29 30 --zone-type database
Boolean checks:
# Your direct example: if index 5's 7th DB value is greater than 8, print yes/no.
"$REG" ref-bool "$DOC" "index:5:db:7" gt 8 --then-val yes --else-val no
# Equivalent spellings. In Bash, quote > and >= so the shell does not redirect.
"$REG" ref-bool "$DOC" "index:5:db:7" ">" 8 --then-val yes --else-val no
"$REG" ref-bool "$DOC" "index:5:db:7" gte 9 --then-val yes --else-val no
"$REG" ref-bool "$DOC" "index:5:db:7" ">=" 9 --then-val yes --else-val no
"$REG" ref-bool "$DOC" "index:5:db:7" lt 10 --then-val yes --else-val no
"$REG" ref-bool "$DOC" "index:5:db:7" "<" 10 --then-val yes --else-val no
"$REG" ref-bool "$DOC" "index:5:db:7" lte 9 --then-val yes --else-val no
"$REG" ref-bool "$DOC" "index:5:db:7" "<=" 9 --then-val yes --else-val no
# Your comparative example: if index 6's 3rd DB value equals index 869's 6th DB value.
"$REG" ref-bool "$DOC" "index:6:db:3" eq "index:869:db:6" --then-val yes --else-val no
"$REG" ref-bool "$DOC" "index:6:db:3" == "index:869:db:6" --then-val yes --else-val no
"$REG" ref-bool "$DOC" "index:6:db:3" = "index:869:db:6" --then-val yes --else-val no
"$REG" ref-bool "$DOC" "index:6:db:3" ne "index:869:db:6" --then-val different --else-val same
# String/zone content checks.
"$REG" ref-bool "$DOC" "index:38:string:1" contains thirty-eight --then-val yes --else-val no
"$REG" ref-bool "$DOC" "index:38:zone:1" contains multiline --then-val yes --else-val no
"$REG" ref-bool "$DOC" "index:38:zonehex:1" contains 0x000001D --then-val yes --else-val no
Writes through ref-set:
"$REG" ref-set "$DOC" "index:38:string:2" --text "updated notes from Bash"
"$REG" ref-get "$DOC" "index:38:string:2"
"$REG" ref-set "$DOC" "index:38:db:7" --text 123
"$REG" ref-get "$DOC" "index:38:db:7"
"$REG" ref-set "$DOC" "index:38:string:3" --from "index:869:string:1"
"$REG" ref-get "$DOC" "index:38:string:3"
printf 'appended line from stdin\n' | "$REG" ref-set "$DOC" "index:38:zone:1" --append
"$REG" ref-get "$DOC" "index:38:zone:1"
printf 'replacement multiline A\nreplacement multiline B\n' | "$REG" ref-set "$DOC" "index:38:zone:1"
"$REG" ref-get "$DOC" "index:38:zone:1"
# Set a defined zone's stored hex range without replacing content.
"$REG" ref-set "$DOC" "index:38:zonehex:1" --text "0x000001D : 0x000001E"
"$REG" index-zone-set-hex "$DOC" 38 1 0x000001D 0x000001E
Copy/move/diff refs:
"$REG" ref-copy "$DOC" "index:869:string:1" "index:38:string:1"
"$REG" ref-copy "$DOC" "index:869:zone:1" "index:38:zone:1"
"$REG" ref-copy "$DOC" "index:869:zone:1" "index:38:zone:1" --append
"$REG" ref-copy "$DOC" "index:869:zone:1" "index:38:zone:1" --move
"$REG" ref-diff "$DOC" "index:6:dbline" "index:869:dbline"
"$REG" ref-diff "$DOC" "index:38:zone:1" "index:869:zone:1"
Undo and state snapshots:
"$REG" state "$DOC" > state-before.json
"$REG" ref-set "$DOC" "index:38:string:1" --text "temporary edit"
"$REG" state-compare "$DOC" state-before.json
"$REG" undo "$DOC"
"$REG" ref-get "$DOC" "index:38:string:1"
Explicit hex range commands:
"$REG" convert 29 30 --zone-type markdown
"$REG" convert 29 30 --zone-type code
"$REG" hex-extract "$DOC" 0x000001D 0x000001E
printf 'new explicit range text\n' | "$REG" hex-replace "$DOC" 0x000001D 0x000001E
"$REG" undo "$DOC"
Index-zone helper commands:
"$REG" index-zone-extract "$DOC" 38 0
"$REG" index-zone-replace "$DOC" 38 0 --text "zone replacement by index helper"
"$REG" undo "$DOC"
"$REG" index-zone-copy "$DOC" --from-index 869 --from-zone 0 --to-index 38 --to-zone 0
"$REG" undo "$DOC"
"$REG" index-zone-transfer --from-file "$DOC" --from-index 869 --from-zone 0 --to-file "$DOC" --to-index 38 --to-zone 0
"$REG" undo "$DOC"
Legacy section helper commands:
"$REG" set-str "$DOC" "index:38" 0 "legacy string zero"
"$REG" set-num "$DOC" "index:38" 6 777
"$REG" set-zone "$DOC" "index:38" 0 29 30 --zone-type markdown
"$REG" grep "$DOC" "index:38" 0
"$REG" zone-extract "$DOC" "index:38" 0
"$REG" zone-replace "$DOC" "index:38" 0 --text "legacy zone replacement"
"$REG" undo "$DOC"
"$REG" zone-append "$DOC" "index:38" 0 --text "legacy append"
"$REG" undo "$DOC"
"$REG" zone-copy "$DOC" "index:869" 0 "index:38" 0
"$REG" undo "$DOC"
Search and old boolean helpers:
"$REG" fgrep "$DOC" "thirty-eight"
"$REG" fgrep "$DOC" "zone" --section "index:38"
"$REG" fgrep-multi "$DOC" "thirty-eight" "eight-six-nine"
"$REG" lines "$DOC" 29 30
"$REG" bool-and "$DOC" "index:38" "multiline" "value"
"$REG" bool-or "$DOC" "index:38" "missing" "multiline"
"$REG" bool-xor "$DOC" "index:38" "multiline" "eight-six-nine"
"$REG" bool-nand "$DOC" "index:38" "multiline" "forbidden"
"$REG" if-contains "$DOC" "index:38" "multiline" --then-val yes --else-val no
"$REG" count "$DOC" "__all__" "index"
Create/copy/replace documents:
"$REG" new new-doc.md "New Regedited Document"
"$REG" add new-doc.md "LegacyNamedSection"
"$REG" rm new-doc.md "LegacyNamedSection"
cp "$DOC" donor.md
"$REG" diff "$DOC" donor.md
"$REG" replace "$DOC" donor.md --output replaced-output.md
"$REG" replace "$DOC" donor.md --sections "index:38" --output replaced-index38.md
WAL, transactions, schema:
"$REG" wal "$DOC"
"$REG" wal-replay "$DOC"
"$REG" wal-replay "$DOC" --apply
"$REG" tx status "$DOC"
"$REG" tx begin "$DOC"
"$REG" tx commit "$DOC"
"$REG" tx rollback "$DOC"
"$REG" schema "$DOC"
"$REG" schema "$DOC" --init
"$REG" schema "$DOC" --validate
Utility commands:
"$REG" types
"$REG" reg-types
"$REG" reg-parse "hello" --reg-type REG_SZ
"$REG" reg-parse 123 --reg-type REG_DWORD
"$REG" getutf 29
"$REG" getutf 0 --decode "1D 00"
"$REG" encap "hello world" --mode b
"$REG" encap "hello world" --mode c
"$REG" encap "hello world" --mode d
"$REG" encap "[\"hello\"]" --extract
"$REG" encap "hello world" --mode b --to d
"$REG" encap "hello world" --set 0aaa
"$REG" echo "$DOC" "index:38" 0
"$REG" echo-direct "literal string with < > & | characters"
HTML attribute extraction:
cat > sample.html <<'EOF'
<a href="/one">one</a>
<img src="/img.png">
<script src="/app.js"></script>
EOF
"$REG" grab-html sample.html href
"$REG" grab-html sample.html src
"$REG" grab-html sample.html src --tag img
"$REG" grab-html sample.html href --mode d --set 0link
"$REG" grab-html sample.html src --numbered
HTTP serve mode:
"$REG" serve --file "$DOC" --port 5000
# In another shell:
curl http://127.0.0.1:5000/
curl http://127.0.0.1:5000/sections
curl http://127.0.0.1:5000/section/index:38/hexline
curl 'http://127.0.0.1:5000/ref?spec=index:38:zonehex:1'
curl 'http://127.0.0.1:5000/ref-bool?left=index:5:db:7&op=gt&right=8'
curl -X POST http://127.0.0.1:5000/query -H 'Content-Type: application/json' -d '{"left":"index:6:db:3","op":"eq","right":"index:869:db:6"}'
Exit code pattern for scripts:
if "$REG" ref-bool "$DOC" "index:5:db:7" gt 8 --then-val yes --else-val no | grep -q yes; then
echo "branch true"
else
echo "branch false"
fi
value="$("$REG" ref-get "$DOC" "index:38:zone:1")"
printf '%s\n' "$value"
hex_range="$("$REG" ref-get "$DOC" "index:38:zonehex:1")"
printf 'defined hex range: %s\n' "$hex_range"
RGD COMPACT WORKFLOW
pathadd.sh creates rgd as a symlink to the release regedited executable and
adds target/release to PATH through the invoking user's .bashrc.
rgd load "$DOC"
rgd load
rgd l
rgd sm
rgd ist 38
rgd rg i38s1
rgd rg i38s1 c
rgd rb i38db7 gte 8 --then-val TRUE --else-val FALSE
rgd rd i38s1 i39s1
rgd cv d 58 p 59
rgd cv b 10 20 m 30 40 d 50 60 c
Source ~/.bashrc after installation if the script cannot update the parent
shell process. An explicit path still overrides the loaded document.