-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTL_DR
653 lines (440 loc) · 11.2 KB
/
TL_DR
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
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
####################
# core/dep.sh
####################
# dep__lib()
Check if a lib of sheli has been loaded and exit with an error if not
# dep__lib_opt()
Check if a lib of sheli has been loaded and return an error code if not
# dep__pkg()
Check if a package (binary, function, etc.) is available and exit with an error if not
# dep__pkg_opt()
Check if a package (binary, function, etc.) is available and return an error code if not
# dep__var()
Check if a variable has been declared and exit with an error if not
# dep__var_opt()
Check if a variable has been declared and returnh an error code if not
####################
# core/font.sh
####################
# font__set()
Enable or disable colors in text
(Options are never, auto and always)
EG font__set never # Disable colors
EG font__set auto # Enable colors if supported by shell
EG font__set always # Enable colors
####################
# ess/argparse.sh
####################
# argparse__add_argument()
Add an argument to be evaluated
EG argparse__add_argument name='varname' flags='-s,--long'
There are several combination to be used.
As a rule of thumb, this implementation of argparse is similar to python-argparse
# TODO Extensive argparse guide
# argparse__description()
Set the description shown in the help message
# argparse__help()
Print the help message
It will exit with an error if it is not called with --help
# argparse__synopsis()
Set the synopsis shown in the help message
# argparse__usage()
Print the usage
It will exit with an error if it is not called with --help or --usage
####################
# ess/debug.sh
####################
# debug__exec()
Execute the code if DEBUG mode is active
# debug__xtrace()
Execute the code with set -x if DEBUG mode is active
####################
# ess/print.sh
####################
# print__bad()
Print text with a "bad" prefix
EG print__bad This is a bad message
-> [-] This is a bad message
# print__blankline()
Erase the current line
EG printf test && print__blankline
->
# print__debug()
Print text with a "debug" prefix if DEBUG mode is active
EG print__debug This is a bebug message
-> [#] This is a bebug message
# print__error()
Print text with a "error" prefix
EG print__error This is an error message
-> [x] This is an error message
# print__good()
Print text with a "good" prefix
EG print__good This is a good message
-> [+] This is a good message
# print__info()
Print text with a "info" prefix
EG print__info This is an info message
-> [*] This is an info message
# print__list()
Print a list with a numerical prefix
EG print__list foo1 bar1 foo2 bar2 foobar1
-> [1] foo1
-> [2] bar1
-> [3] foo2
-> [4] bar2
-> [5] foobar1
# print__question()
Print text with a "question" prefix
EG print__info This is a question
-> [?] This is a question
# print__timestamp()
Print text with a "timestamp" prefix
EG print__info This is a timestamp message
-> [20210615T093906+0200] This is a timestamp message
# print__warning()
Print text with a "warning" prefix
EG print__info This is a warning message
-> [!] This is a warning message
# print__wheel()
Print text with a "wheel" prefix
The wheel will cycle a sequence (".oO0Oo. " by default)
EG print__wheel This is a waiting message
-> [.] This is a warning message
-> [o] This is a warning message
-> [O] This is a warning message
-> [0] This is a warning message
-> [O] This is a warning message
-> [o] This is a warning message
-> [.] This is a warning message
-> [ ] This is a warning message
Every line will replace the previous one
####################
# ess/time.sh
####################
# time__time()
Return the time from /proc/uptime
EG time__time
-> 1093362
# time__uptime()
Return the uptime in milliseconds
EG time__uptime
-> 3141
####################
# sheli.sh
####################
# sheli__main()
Start the engine
Virtually this should always be at the bottom of every script that uses sheli
####################
# util/cast.sh
####################
# bin2dec()
Convert a binary number into a decimal number
EG bin2dec 11100011
-> 227
# bin2hex()
Convert a binary number into a hexadecimal number
EG bin2hex 11100011
-> 0xE3
# bin2oct()
Convert a binary number into an octal number
EG bin2oct 11100011
-> 343
# cast__set_scale()
Set the scale for float numers
# char2int()
Convert a character into a integer number
EG char2int A
-> 65
# cidr2netmask()
Convert a cidr netmask into an ipv4 netmask
EG cidr2netmask 24
-> 255.255.255.0
# date2epoch()
Convert a date into an epoch date
EG date2epoch 'Fri 11 Jun 2021 12:15:42 PM CEST'
-> 1623406542
# dec2bin()
Convert a decimal number into a binary number
EG dec2bin 227
-> 11100011
# dec2hex()
Convert a decimal number into a hexadecimal number
EG dec2hex 227
-> E3
# dec2oct()
Convert a decimal number into an octal number
EG dec2oct 227
-> 343
# epoch2date()
Convert an epoch date into a date
EG epoch2date 1623406542
-> Fri 11 Jun 2021 12:15:42 PM CEST
# epoch2wints()
Convert an epoch date into a Windows timestamp date
EG epoch2wints 1623406542
-> 132678801420000000
# float2int()
Convert a float number into an integer number
EG float2int 3.14159
-> 3
# hex2bin()
Convert a hexadecimal number into a binary number
EG hex2bin E3
-> 11100011
# hex2dec()
Convert a hexadecimal number into a decimal number
EG hex2dec E3
-> 227
# hex2oct()
Convert a hexadecimal number into an octal number
EG hex2oct E3
-> 343
# int2char()
Convert an integer number into a character
EG int2char 65
-> A
# int2float()
Convert an integer number into a float number
EG int2float 3
-> 3.00 # Note: Number of zeroes depends on scale
# int2ip()
Convert an integer number into an ipv4 address
EG int2ip 3232235777
-> 192.168.1.1
# ip2int()
Convert an ipv4 address into an integer number
EG ip2int 192.168.1.1
-> 3232235777
# oct2bin()
Convert an octal number into a binary number
EG oct2bin 343
-> 11100011
# oct2dec()
Convert an octal number into a decimal number
EG oct2dec 343
-> 227
# oct2hex()
Convert an octal number into a hexadecimal number
EG oct2hex 343
-> E3
# str2chars()
Convert a string into a list of characters
EG str2chars goatse
g o a t s e
# wints2epoch()
convert a Windows timestamp date into an epoch date
EG wints2epoch 132678801420000000
-> 1623406542
####################
# util/check.sh
####################
# check__alnum()
# check__alpha()
# check__base64()
# check__bin()
# check__cidr()
# check__date()
# check__debug_alnum()
# check__debug_alpha()
# check__debug_base64()
# check__debug_bin()
# check__debug_cidr()
# check__debug_date()
# check__debug_digit()
# check__debug_epoch()
# check__debug_float()
# check__debug_hex()
# check__debug_int()
# check__debug_ipv4()
# check__debug_md5()
# check__debug_negative()
# check__debug_null()
# check__debug_number()
# check__debug_oct()
# check__debug_port()
# check__debug_positive()
# check__debug_prefix()
# check__debug_sha1()
# check__debug_sha256()
# check__debug_sha512()
# check__debug_socket()
# check__debug_wints()
# check__digit()
# check__epoch()
# check__error_alnum()
# check__error_alpha()
# check__error_base64()
# check__error_bin()
# check__error_cidr()
# check__error_date()
# check__error_digit()
# check__error_epoch()
# check__error_float()
# check__error_hex()
# check__error_int()
# check__error_ipv4()
# check__error_md5()
# check__error_negative()
# check__error_null()
# check__error_number()
# check__error_oct()
# check__error_port()
# check__error_positive()
# check__error_prefix()
# check__error_sha1()
# check__error_sha256()
# check__error_sha512()
# check__error_socket()
# check__error_wints()
# check__float()
# check__hex()
# check__info_alnum()
# check__info_alpha()
# check__info_base64()
# check__info_bin()
# check__info_cidr()
# check__info_date()
# check__info_digit()
# check__info_epoch()
# check__info_float()
# check__info_hex()
# check__info_int()
# check__info_ipv4()
# check__info_md5()
# check__info_negative()
# check__info_null()
# check__info_number()
# check__info_oct()
# check__info_port()
# check__info_positive()
# check__info_prefix()
# check__info_sha1()
# check__info_sha256()
# check__info_sha512()
# check__info_socket()
# check__info_wints()
# check__int()
# check__ipv4()
# check__md5()
# check__negative()
# check__null()
# check__number()
# check__oct()
# check__port()
# check__positive()
# check__prefix()
# check__sha1()
# check__sha256()
# check__sha512()
# check__socket()
# check__warning_alnum()
# check__warning_alpha()
# check__warning_base64()
# check__warning_bin()
# check__warning_cidr()
# check__warning_date()
# check__warning_digit()
# check__warning_epoch()
# check__warning_float()
# check__warning_hex()
# check__warning_int()
# check__warning_ipv4()
# check__warning_md5()
# check__warning_negative()
# check__warning_null()
# check__warning_number()
# check__warning_oct()
# check__warning_port()
# check__warning_positive()
# check__warning_prefix()
# check__warning_sha1()
# check__warning_sha256()
# check__warning_sha512()
# check__warning_socket()
# check__warning_wints()
# check__wints()
####################
# util/config.sh
####################
The config file is meant to be a simple .ini, divided in sections:
EG file.ini
[section1]
var1 = value1
var2 = value2
[section2]
var1 = value1
Spaces should not be a problem
# config__get()
Return the value of a variable in the config file
# config__getint()
Return the value of a variable in the config file checking it as interger
####################
# util/math.sh
####################
# pow()
Return the power of base and exponent
EG pow 2 8
-> 256
# rand()
Return a random number between 0 and 4294967295
####################
# util/override.sh
####################
# sleep()
Override the standard sleep, adding a graphic feedback
# wait()
Override the standard wait, adding a graphic feedback # Monitor mode is needed
####################
# util/test.sh
####################
# is_alnum()
Check if the argument is an alphanumeric string
# is_alpha()
Check if the argument is an alphabetic string
# is_base64()
Check if the argument is a base64 string
# is_bin()
Check if the argument is a binary number
# is_cidr()
Check if the argument is a cidr netmask
# is_date()
Check if the argument is a date
# is_digit()
Check if the argument is a digits string
# is_epoch()
Check if the argument is an epoch date
# is_float()
Check if the argument is a float number
# is_hex()
Check if the argument is a hexadecimal number
# is_int()
Check if the argument is an integer number
# is_ipv4()
Check if the argument is an ipv4 address
# is_md5()
Check if the argument is a md5 hash
# is_negative()
Check if the argument is a negative number (0 not included)
# is_null()
Check if the argument is equal to $NULL
# is_number()
Check if the argument is a number # Note: alias for is_float()
# is_oct()
Check if the argument is an octal number
# is_port()
Check if the argument is a port
# is_positive()
Check if the argument is a positive number (0 not included)
# is_prefix()
Check if the argument is a prefix # Note: ipv4/cidr
# is_sha1()
Check if the argument is a sha1 hash
# is_sha256()
Check if the argument is a sha256 hash
# is_sha512()
Check if the argument is a sha512 hash
# is_socket()
Check if the argument is a socket # Note: ipv4:port
# is_wints()
Check if the argument is a Winwdows timestamp date