-
Notifications
You must be signed in to change notification settings - Fork 0
/
post-bootstrap.sh
executable file
·3371 lines (2871 loc) · 163 KB
/
post-bootstrap.sh
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
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env sh
# shellcheck disable=SC2317
# disable shellcheck checking for unreachable code, b/c it doesn't understand
# mshext's def and call keywords
# "$_" undefined in POSIX, we only use it for specific shells
# shellcheck disable=SC3028
DOLLAR_UNDER="$_"
# NOTE: Edit the function 'post_bootstrap' (in region 'Public *') to include
# your project's custom setup
# NOTE: This file needs to abide by POSIX requirements for the most part in
# order to be cross compatible between platforms/shells. Compatibility with
# 'dash', 'bash --posix', and 'zsh --emulate sh' are the goal; 'dash' appears
# to be the most strict, so you can use that as your baseline.
# TODO: add includes for bfi-base & bfi (to allow running from top level for manual testing)
# TODO: add do_deploy function
################################################################################
#region marximus-shell-extensions Base Preamble
if [ "${__MARXIMUS_SHELL_EXTENSIONS__GLOBAL__OPTIONS_OLD}" = "" ]; then
__MARXIMUS_SHELL_EXTENSIONS__GLOBAL__OPTIONS_OLD="${-:+"-$-"}"
fi
# check if probably zsh (if the -y "shwordsplit" option exists)
if [ "$(set -o | grep "^shwordsplit")" != "" ]; then
# shellcheck disable=3041
set -y
fi
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__OPTIONS_OLD="${-:+"-$-"}"
set +x; if [ -n "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__ENABLE_TRACE}" ]; then set -x; else set +x; fi
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__OPTIONS_OLD="$(echo "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__OPTIONS_OLD}" | sed 's/c//g')"
# fence to prevent redefinition
type MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE_FENCE >/dev/null 2>&1
ret=$?
if [ "$ret" -ne 0 ]; then
# NOTE: fence is created later
# Call Stack Tracking needs to be in multiple parts, because aliases
# cannot be declared and used within the same if block
#===============================================================================
#region Call Stack Tracking Part 1
PS4="+ \${__array__SHELL_CALL_STACK_DEST_PUUID__peek}:\${__array__SHELL_CALL_STACK_FUNCNAME__peek}:\$LINENO: "
#-------------------------------------------------------------------------------
# line offset checking
test_LINENO_GLOBAL_OFFSET() { echo "$LINENO"; }
LINENO_GLOBAL_OFFSET="$(test_LINENO_GLOBAL_OFFSET)"
LINENO_IS_RELATIVE=false
if [ "$LINENO_GLOBAL_OFFSET" = "" ]; then
LINENO_GLOBAL_OFFSET=0
elif [ "$LINENO_GLOBAL_OFFSET" -le 1 ]; then
LINENO_IS_RELATIVE=true
else
LINENO_GLOBAL_OFFSET=0
fi
unset -f test_LINENO_GLOBAL_OFFSET
export LINENO_GLOBAL_OFFSET
export LINENO_IS_RELATIVE
OPTION_SETTRACE=false
if [ "$(echo "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__OPTIONS_OLD}" | grep -e 'x')" != "" ]; then
OPTION_SETTRACE=true
fi
export OPTION_SETTRACE
# only checking WAS_SOURCED b/c if it isn't set, none of them should be, as
# a runtime optimization
if [ "${WAS_SOURCED}" = "" ]; then
# WAS_SOURCED & SHELL_SOURCE & SHELL_SOURCE_PUUID are index aligned arrays
# WAS_SOURCED array of sourcing info of the files; true if file was
# sourced, false if file was invoked
# SHELL_SOURCE array of paths to the files
# SHELL_SOURCE_PUUID array of PUUIDs of the files
# SHELL_SOURCE_PUUID_TO_PATH_DICT dictionary whose keys are both paths
# and puuids, whose values are paths
# SHELL_SOURCE_PATH_TO_PUUID_DICT dictionary whose keys are both paths
# and puuids, whose values are puuids
# SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID dictionary whose keys are function
# names to the file's puuid where they were last defined
# SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO dictionary whose keys are function
# names to the line number in the file where they were last defined
# SHELL_CALL_STACK array of the call stack in the format:
# src_puuid:src_lineno:parent_funcname:dest_puuid:dest_lineno:funcname args
# SHELL_CALL_STACK_SOURCE_PUUID array of the call stack's source puuids
# SHELL_CALL_STACK_DEST_PUUID array of the call stack's destination ppuids
# SHELL_CALL_STACK_FUNCNAME array of the call stack's function names
# unrolled array_init & array_export begin (optimized)
# nullcall array_init WAS_SOURCED
WAS_SOURCED="__array__"
export WAS_SOURCED
__array__WAS_SOURCED="__array__"
export __array__WAS_SOURCED
__array__WAS_SOURCED__length=0
export __array__WAS_SOURCED__length
__array__WAS_SOURCED__peek=""
export __array__WAS_SOURCED__peek
# unrolled array_init & array_export end
# unrolled array_init & array_export begin (optimized)
# nullcall array_init SHELL_SOURCE
SHELL_SOURCE="__array__"
export SHELL_SOURCE
__array__SHELL_SOURCE="__array__"
export __array__SHELL_SOURCE
__array__SHELL_SOURCE__length=0
export __array__SHELL_SOURCE__length
__array__SHELL_SOURCE__peek=""
export __array__SHELL_SOURCE__peek
# unrolled array_init & array_export end
# unrolled array_init & array_export begin (optimized)
# nullcall array_init SHELL_SOURCE_PUUID
SHELL_SOURCE_PUUID="__array__"
export SHELL_SOURCE_PUUID
__array__SHELL_SOURCE_PUUID="__array__"
export __array__SHELL_SOURCE_PUUID
__array__SHELL_SOURCE_PUUID__length=0
export __array__SHELL_SOURCE_PUUID__length
__array__SHELL_SOURCE_PUUID__peek=""
export __array__SHELL_SOURCE_PUUID__peek
# unrolled array_init & array_export end
# unrolled dict_init & dict_init begin (optimized)
# nullcall dict_init SHELL_SOURCE_PUUID_TO_PATH_DICT
SHELL_SOURCE_PUUID_TO_PATH_DICT="__dict__"
export SHELL_SOURCE_PUUID_TO_PATH_DICT
__dict__SHELL_SOURCE_PUUID_TO_PATH_DICT="__dict__"
export __dict__SHELL_SOURCE_PUUID_TO_PATH_DICT
__dict__SHELL_SOURCE_PUUID_TO_PATH_DICT__length=0
export __dict__SHELL_SOURCE_PUUID_TO_PATH_DICT__length
__dict__SHELL_SOURCE_PUUID_TO_PATH_DICT__keys="__array__"
export __dict__SHELL_SOURCE_PUUID_TO_PATH_DICT__keys
__array____dict__SHELL_SOURCE_PUUID_TO_PATH_DICT__keys="__array__"
export __array____dict__SHELL_SOURCE_PUUID_TO_PATH_DICT__keys
__array____dict__SHELL_SOURCE_PUUID_TO_PATH_DICT__keys__length=0
export __array____dict__SHELL_SOURCE_PUUID_TO_PATH_DICT__keys__length
__array____dict__SHELL_SOURCE_PUUID_TO_PATH_DICT__keys__peek=""
export __array____dict__SHELL_SOURCE_PUUID_TO_PATH_DICT__keys__peek
# unrolled dict_init & dict_init end
# unrolled dict_init & dict_init begin (optimized)
# nullcall dict_init SHELL_SOURCE_PATH_TO_PUUID_DICT
SHELL_SOURCE_PATH_TO_PUUID_DICT="__dict__"
export SHELL_SOURCE_PATH_TO_PUUID_DICT
__dict__SHELL_SOURCE_PATH_TO_PUUID_DICT="__dict__"
export __dict__SHELL_SOURCE_PATH_TO_PUUID_DICT
__dict__SHELL_SOURCE_PATH_TO_PUUID_DICT__length=0
export __dict__SHELL_SOURCE_PATH_TO_PUUID_DICT__length
__dict__SHELL_SOURCE_PATH_TO_PUUID_DICT__keys="__array__"
export __dict__SHELL_SOURCE_PATH_TO_PUUID_DICT__keys
__array____dict__SHELL_SOURCE_PATH_TO_PUUID_DICT__keys="__array__"
export __array____dict__SHELL_SOURCE_PATH_TO_PUUID_DICT__keys
__array____dict__SHELL_SOURCE_PATH_TO_PUUID_DICT__keys__length=0
export __array____dict__SHELL_SOURCE_PATH_TO_PUUID_DICT__keys__length
__array____dict__SHELL_SOURCE_PATH_TO_PUUID_DICT__keys__peek=""
export __array____dict__SHELL_SOURCE_PATH_TO_PUUID_DICT__keys__peek
# unrolled dict_init & dict_init end
# unrolled dict_init & dict_init begin (optimized)
# nullcall dict_init SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID
# nullcall dict_export SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID
SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID="__dict__"
export SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID
__dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID="__dict__"
export __dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID
__dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__length=0
export __dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__length
__dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keys="__array__"
export __dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keys
__array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keys="__array__"
export __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keys
__array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keys__length=0
export __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keys__length
__array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keys__peek=""
export __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keys__peek
# unrolled dict_init & dict_init end
# unrolled dict_init & dict_init begin (optimized)
# nullcall dict_init SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO
# nullcall dict_export SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO
SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO="__dict__"
export SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO
__dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO="__dict__"
export __dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO
__dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__length=0
export __dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__length
__dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keys="__array__"
export __dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keys
__array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keys="__array__"
export __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keys
__array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keys__length=0
export __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keys__length
__array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keys__peek=""
export __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keys__peek
# unrolled dict_init & dict_init end
# unrolled array_init & array_export begin (optimized)
# nullcall array_init SHELL_CALL_STACK
# nullcall array_export SHELL_CALL_STACK
SHELL_CALL_STACK="__array__"
export SHELL_CALL_STACK
__array__SHELL_CALL_STACK="__array__"
export __array__SHELL_CALL_STACK
__array__SHELL_CALL_STACK__length=0
export __array__SHELL_CALL_STACK__length
__array__SHELL_CALL_STACK__peek=""
export __array__SHELL_CALL_STACK__peek
# unrolled array_init end
# unrolled array_init & array_export begin (optimized)
# nullcall array_init SHELL_CALL_STACK_SOURCE_PUUID
SHELL_CALL_STACK_SOURCE_PUUID="__array__"
export SHELL_CALL_STACK_SOURCE_PUUID
__array__SHELL_CALL_STACK_SOURCE_PUUID="__array__"
export __array__SHELL_CALL_STACK_SOURCE_PUUID
__array__SHELL_CALL_STACK_SOURCE_PUUID__length=0
export __array__SHELL_CALL_STACK_SOURCE_PUUID__length
__array__SHELL_CALL_STACK_SOURCE_PUUID__peek=""
export __array__SHELL_CALL_STACK_SOURCE_PUUID__peek
# unrolled array_init end
# unrolled array_init & array_export begin (optimized)
# nullcall array_init SHELL_CALL_STACK_DEST_PUUID
SHELL_CALL_STACK_DEST_PUUID="__array__"
export SHELL_CALL_STACK_DEST_PUUID
__array__SHELL_CALL_STACK_DEST_PUUID="__array__"
export __array__SHELL_CALL_STACK_DEST_PUUID
__array__SHELL_CALL_STACK_DEST_PUUID__length=0
export __array__SHELL_CALL_STACK_DEST_PUUID__length
__array__SHELL_CALL_STACK_DEST_PUUID__peek=""
export __array__SHELL_CALL_STACK_DEST_PUUID__peek
# unrolled array_init end
# unrolled array_init & array_export begin (optimized)
# nullcall array_init SHELL_CALL_STACK_FUNCNAME
SHELL_CALL_STACK_FUNCNAME="__array__"
export SHELL_CALL_STACK_FUNCNAME
__array__SHELL_CALL_STACK_FUNCNAME="__array__"
export __array__SHELL_CALL_STACK_FUNCNAME
__array__SHELL_CALL_STACK_FUNCNAME__length=0
export __array__SHELL_CALL_STACK_FUNCNAME__length
__array__SHELL_CALL_STACK_FUNCNAME__peek=""
export __array__SHELL_CALL_STACK_FUNCNAME__peek
# unrolled array_init end
fi
#-------------------------------------------------------------------------------
# def; keyword
# 'true' is a command that returns 0 and is effectively a no-op command
# so when 'def;' used to declare a function:
# def; foo() {}
# ^ NOTE: the semicolon
# it will do essentially nothing (which is what we want!)
alias nulldef="true"
#endregion Call Stack Tracking Part 1
#===============================================================================
fi
# NOTE: Separation b/c cannot define and then use aliases in same block
# fence to prevent redefinition
type MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE_FENCE >/dev/null 2>&1
ret=$?
if [ "$ret" -ne 0 ]; then
# NOTE: fence is created later
#===============================================================================
#region Call Stack Tracking Part 2
#-------------------------------------------------------------------------------
# "def;" keyword
# when 'def;' used to declare a function:
# def; foo() {}
# ^ NOTE: the semicolon
# it will track the puuid of the file where the function is declared and
# the true line number where the function is declared in that file
nulldef; def_G() {
true lies; __MARXIMUS_SHELL_EXTENSIONS__def_G__OPTIONS_OLD="${-:+"-$-"}"
true lies; set +x
true lies; __MARXIMUS_SHELL_EXTENSIONS__def_G__OPTIONS_OLD="$(echo "${__MARXIMUS_SHELL_EXTENSIONS__def_G__OPTIONS_OLD}" | sed 's/c//g')"
# incoming $LINENO
true lies; __def_G_lineno=$1
# get the current context's puuid from the call stack
# unrolled array_peek begin (optimized)
# __def_G_puuid="$(nullcall array_peek SHELL_CALL_STACK_SOURCE_PUUID)"
# true lies; __def_G_puuid__index=$(( __array__SHELL_CALL_STACK_SOURCE_PUUID__length - 1 ))
# true lies; eval "__def_G_puuid=\${__array__SHELL_CALL_STACK_SOURCE_PUUID__index__${__def_G_puuid__index}}"
# shellcheck disable=SC2154
{
true lies; __def_G_puuid="${__array__SHELL_CALL_STACK_DEST_PUUID__peek}"
}
# unrolled array_peek end
# get the real filepath of the puuid
# unrolled dict_get_key begin (optimized)
# __def_G_filepath="$(nullcall dict_get_key SHELL_SOURCE_PUUID_TO_PATH_DICT "${__def_G_puuid}")"
# shellcheck disable=SC2154
{
true lies; __def_G_filepath__key_hash="$( (printf "%s" "${__def_G_puuid}" | sha1sum 2>/dev/null; test $? = 127 && printf "%s" "${__def_G_puuid}" | shasum -a 1) | cut -d' ' -f1)"
}
true lies; eval "__def_G_filepath=\"\${__dict__SHELL_SOURCE_PUUID_TO_PATH_DICT__keyhash__${__def_G_filepath__key_hash}__value}\""
true lies; unset __def_G_filepath__key_hash
# unrolled dict_get_key end
# get the context's func name from the call stack
# unrolled array_peek begin (optimized)
# __def_G_parent_funcname="$(nullcall array_peek SHELL_CALL_STACK_FUNCNAME)"
# true lies; __def_G_parent_funcname__index=$(( __array__SHELL_CALL_STACK_FUNCNAME__length - 1 ))
# true lies; eval "__def_G_parent_funcname=\${__array__SHELL_CALL_STACK_FUNCNAME__index__${__def_G_parent_funcname__index}}"
# shellcheck disable=SC2154
{
true lies; __def_G_parent_funcname="${__array__SHELL_CALL_STACK_FUNCNAME__peek}"
}
# unrolled array_peek end
true lies; if [ "${LINENO_IS_RELATIVE}" = true ]; then
# get the current parent's lineno
# unrolled dict_get_key begin (optimized)
# __def_G_parent_lineno_offset=$(nullcall dict_get_key SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO "${__def_G_parent_funcname}")
# shellcheck disable=SC2154
{
true lies; __def_G_parent_lineno_offset__key_hash="$( (printf "%s" "${__def_G_parent_funcname}" | sha1sum 2>/dev/null; test $? = 127 && printf "%s" "${__def_G_parent_funcname}" | shasum -a 1) | cut -d' ' -f1)"
}
true lies; eval "__def_G_parent_lineno_offset=\"\${__dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keyhash__${__def_G_parent_lineno_offset__key_hash}__value}\""
true lies; unset __def_G_parent_lineno_offset__key_hash
# unrolled dict_get_key end
# shellcheck disable=SC2154
{
true lies; if [ "${__def_G_parent_lineno_offset}" != "" ]; then
# recalculate lineno to account for parent's lineno and the global offset
# shellcheck disable=SC2154
true lies; __def_G_lineno=$(( __def_G_lineno + __def_G_parent_lineno_offset - LINENO_GLOBAL_OFFSET ))
true lies; fi
}
true lies; fi
# get the func's real name
# shellcheck disable=SC2154
# echo __def_G_funcname="\$(head -n \"$__def_G_lineno\" \"$__def_G_filepath\" | tail -n 1 | awk '{ print $2 }' | tr -d '()')"
# shellcheck disable=SC2154
__def_G_funcname="$(head -n "$__def_G_lineno" "$__def_G_filepath" | tail -n 1 | awk '{ print $2 }' | tr -d '()')"; true lies
# unrolled dict_set_key & dict_export begin (optimized)
# nullcall dict_set_key SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID "$__def_G_funcname" "$__def_G_puuid"
# nullcall dict_export SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID
# nullcall dict_set_key SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO "$__def_G_funcname" "$__def_G_lineno"
# nullcall dict_export SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO
true lies; __def_G_funcname__key_hash="$( (printf "%s" "${__def_G_funcname}" | sha1sum 2>/dev/null; test $? = 127 && printf "%s" "${__def_G_funcname}" | shasum -a 1) | cut -d' ' -f1)"
true lies; eval "__array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keys__index__${__array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keys__length}=\"${__def_G_funcname}\""
true lies; eval "export __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keys__index__${__array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keys__length}"
true lies; __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keys__peek="${__def_G_funcname}"
true lies; export __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keys__peek
true lies; __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keys__length=$(( __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keys__length + 1 ))
true lies; export __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keys__length
true lies; eval "__dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keyhash__${__def_G_funcname__key_hash}__key=\"${__def_G_funcname}\""
true lies; eval "export __dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keyhash__${__def_G_funcname__key_hash}__key"
true lies; eval "__dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keyhash__${__def_G_funcname__key_hash}__value=\"${__def_G_puuid}\""
true lies; eval "export __dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keyhash__${__def_G_funcname__key_hash}__value"
true lies; __dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__length=$(( __dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__length + 1 ))
true lies; export __dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__length
true lies; eval "__array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keys__index__${__array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keys__length}=\"${__def_G_funcname}\""
true lies; eval "export __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keys__index__${__array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keys__length}"
true lies; __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keys__peek="${__def_G_funcname}"
true lies; export __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keys__peek
true lies; __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keys__length=$(( __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keys__length + 1 ))
true lies; export __array____dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keys__length
true lies; eval "__dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keyhash__${__def_G_funcname__key_hash}__key=\"${__def_G_funcname}\""
true lies; eval "export __dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keyhash__${__def_G_funcname__key_hash}__key"
true lies; eval "__dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keyhash__${__def_G_funcname__key_hash}__value=\"${__def_G_lineno}\""
true lies; eval "export __dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keyhash__${__def_G_funcname__key_hash}__value"
true lies; __dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__length=$(( __dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__length + 1 ))
true lies; export __dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__length
true lies; unset __def_G_funcname__key_hash
# unrolled dict_set_key & dict_export end
true lies; if [ "${OPTION_SETTRACE}" = true ]; then
true lies; echo "= ${__def_G_puuid}:${__def_G_lineno}:${__def_G_funcname}"
true lies; fi
# shellcheck disable=SC2086
{
true lies; set +x ${__MARXIMUS_SHELL_EXTENSIONS__def_G__OPTIONS_OLD}
}
}
# shellcheck disable=SC2142
if [ "${OPTION_SETTRACE}" = true ]; then
alias def="def_G \"\$LINENO\""
else
alias def="true"
fi
#endregion Call Stack Tracking Part 2
#===============================================================================
fi
# NOTE: Separation b/c cannot define and then use aliases in same block
# fence to prevent redefinition
type MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE_FENCE >/dev/null 2>&1
ret=$?
if [ "$ret" -ne 0 ]; then
# NOTE: fence is created later
#===============================================================================
#region Call Stack Tracking Part 3
#-------------------------------------------------------------------------------
# nullcall keyword
# emulates how 'call' works, but does not modify shell options nor track
# the call stack
nulldef; nullcall() {
"$@"
return "$?"
}
#-------------------------------------------------------------------------------
# pushes function call context onto call stack
nulldef; _call_stack_push_G() {
# __call_G_source_puuid="$1"
# __call_G_lineno="$2"
# __call_G_dest_puuid="$3"
# __call_G_dest_lineno="$4"
# __call_G_funcname="$5"
# __call_G_parent_funcname="$6"
# unrolled array_push & array_export begin (optimized)
# nullcall array_push SHELL_CALL_STACK "$1:$2:$3:$4:$5"
# nullcall array_export SHELL_CALL_STACK
eval "__array__SHELL_CALL_STACK__index__${__array__SHELL_CALL_STACK__length}=\"$1:$2:$6:$3:$4:$5\""
eval "export __array__SHELL_CALL_STACK__index__${__array__SHELL_CALL_STACK__length}"
__array__SHELL_CALL_STACK__peek="$1:$2:$6:$3:$4:$5"
export __array__SHELL_CALL_STACK__peek
__array__SHELL_CALL_STACK__length=$(( __array__SHELL_CALL_STACK__length + 1 ))
export __array__SHELL_CALL_STACK__length
# unrolled array_push & array_export end
# unrolled array_push & array_export begin (optimized)
# nullcall array_push SHELL_CALL_STACK_SOURCE_PUUID "$1"
# nullcall array_export SHELL_CALL_STACK_SOURCE_PUUID
eval "__array__SHELL_CALL_STACK_SOURCE_PUUID__index__${__array__SHELL_CALL_STACK_SOURCE_PUUID__length}=\"$1\""
eval "export __array__SHELL_CALL_STACK_SOURCE_PUUID__index__${__array__SHELL_CALL_STACK_SOURCE_PUUID__length}"
__array__SHELL_CALL_STACK_SOURCE_PUUID__peek="$1"
export __array__SHELL_CALL_STACK_SOURCE_PUUID__peek
__array__SHELL_CALL_STACK_SOURCE_PUUID__length=$(( __array__SHELL_CALL_STACK_SOURCE_PUUID__length + 1 ))
export __array__SHELL_CALL_STACK_SOURCE_PUUID__length
# unrolled array_push & array_export end
# nullcall array_push SHELL_CALL_STACK_SOURCE_LINENO "$2"
# nullcall array_export SHELL_CALL_STACK_SOURCE_LINENO
# unrolled array_push & array_export begin (optimized)
# nullcall array_push SHELL_CALL_STACK_DEST_PUUID "$3"
# nullcall array_export SHELL_CALL_STACK_DEST_PUUID
eval "__array__SHELL_CALL_STACK_DEST_PUUID__index__${__array__SHELL_CALL_STACK_DEST_PUUID__length}=\"$3\""
eval "export __array__SHELL_CALL_STACK_DEST_PUUID__index__${__array__SHELL_CALL_STACK_DEST_PUUID__length}"
__array__SHELL_CALL_STACK_DEST_PUUID__peek="$3"
export __array__SHELL_CALL_STACK_DEST_PUUID__peek
__array__SHELL_CALL_STACK_DEST_PUUID__length=$(( __array__SHELL_CALL_STACK_DEST_PUUID__length + 1 ))
export __array__SHELL_CALL_STACK_DEST_PUUID__length
# unrolled array_push & array_export end
# nullcall array_push SHELL_CALL_STACK_DEST_LINENO "$4"
# nullcall array_export SHELL_CALL_STACK_DEST_LINENO
# unrolled array_push & array_export begin (optimized)
# nullcall array_push SHELL_CALL_STACK_FUNCNAME "$5"
# nullcall array_export SHELL_CALL_STACK_FUNCNAME
eval "__array__SHELL_CALL_STACK_FUNCNAME__index__${__array__SHELL_CALL_STACK_FUNCNAME__length}=\"$5\""
eval "export __array__SHELL_CALL_STACK_FUNCNAME__index__${__array__SHELL_CALL_STACK_FUNCNAME__length}"
__array__SHELL_CALL_STACK_FUNCNAME__peek="$5"
export __array__SHELL_CALL_STACK_FUNCNAME__peek
__array__SHELL_CALL_STACK_FUNCNAME__length=$(( __array__SHELL_CALL_STACK_FUNCNAME__length + 1 ))
export __array__SHELL_CALL_STACK_FUNCNAME__length
# unrolled array_push & array_export end
}
#-------------------------------------------------------------------------------
# pops function call context off of call stack
nulldef; _call_stack_pop_G() {
# __call_G_source_puuid="$1"
# __call_G_lineno="$2"
# __call_G_dest_puuid="$3"
# __call_G_dest_lineno="$4"
# __call_G_funcname="$5"
# __call_G_parent_funcname="$6"
# unrolled array_pop & array_export begin (optimized)
# nullcall array_pop SHELL_CALL_STACK
# nullcall array_export SHELL_CALL_STACK
__array__SHELL_CALL_STACK__length=$(( __array__SHELL_CALL_STACK__length - 1 ))
export __array__SHELL_CALL_STACK__length
eval "unset __array__SHELL_CALL_STACK__index__${__array__SHELL_CALL_STACK__length}"
__array__SHELL_CALL_STACK__last_index=$(( __array__SHELL_CALL_STACK__length - 1 ))
eval "__array__SHELL_CALL_STACK__peek=\"\${__array__SHELL_CALL_STACK__index__${__array__SHELL_CALL_STACK__last_index}}\""
export __array__SHELL_CALL_STACK__peek
unset __array__SHELL_CALL_STACK__last_index
# unrolled array_pop & array_export end
# unrolled array_pop & array_export begin (optimized)
# nullcall array_pop SHELL_CALL_STACK_SOURCE_PUUID
# nullcall array_export SHELL_CALL_STACK_SOURCE_PUUID
__array__SHELL_CALL_STACK_SOURCE_PUUID__length=$(( __array__SHELL_CALL_STACK_SOURCE_PUUID__length - 1 ))
export __array__SHELL_CALL_STACK_SOURCE_PUUID__length
eval "unset __array__SHELL_CALL_STACK_SOURCE_PUUID__index__${__array__SHELL_CALL_STACK_SOURCE_PUUID__length}"
__array__SHELL_CALL_STACK_SOURCE_PUUID__last_index=$(( __array__SHELL_CALL_STACK_SOURCE_PUUID__length - 1 ))
eval "__array__SHELL_CALL_STACK_SOURCE_PUUID__peek=\"\${__array__SHELL_CALL_STACK_SOURCE_PUUID__index__${__array__SHELL_CALL_STACK_SOURCE_PUUID__last_index}}\""
export __array__SHELL_CALL_STACK_SOURCE_PUUID__peek
unset __array__SHELL_CALL_STACK_SOURCE_PUUID__last_index
# unrolled array_pop & array_export end
# nullcall array_pop SHELL_CALL_STACK_SOURCE_LINENO
# nullcall array_export SHELL_CALL_STACK_SOURCE_LINENO
# unrolled array_pop & array_export begin (optimized)
# nullcall array_pop SHELL_CALL_STACK_DEST_PUUID
# nullcall array_export SHELL_CALL_STACK_DEST_PUUID
__array__SHELL_CALL_STACK_DEST_PUUID__length=$(( __array__SHELL_CALL_STACK_DEST_PUUID__length - 1 ))
export __array__SHELL_CALL_STACK_DEST_PUUID__length
eval "unset __array__SHELL_CALL_STACK_DEST_PUUID__index__${__array__SHELL_CALL_STACK_DEST_PUUID__length}"
__array__SHELL_CALL_STACK_DEST_PUUID__last_index=$(( __array__SHELL_CALL_STACK_DEST_PUUID__length - 1 ))
eval "__array__SHELL_CALL_STACK_DEST_PUUID__peek=\"\${__array__SHELL_CALL_STACK_DEST_PUUID__index__${__array__SHELL_CALL_STACK_DEST_PUUID__last_index}}\""
export __array__SHELL_CALL_STACK_DEST_PUUID__peek
unset __array__SHELL_CALL_STACK_DEST_PUUID__last_index
# unrolled array_pop & array_export end
# nullcall array_pop SHELL_CALL_STACK_DEST_LINENO
# nullcall array_export SHELL_CALL_STACK_DEST_LINENO
# unrolled array_pop & array_export begin (optimized)
# nullcall array_pop SHELL_CALL_STACK_FUNCNAME
# nullcall array_export SHELL_CALL_STACK_FUNCNAME
__array__SHELL_CALL_STACK_FUNCNAME__length=$(( __array__SHELL_CALL_STACK_FUNCNAME__length - 1 ))
export __array__SHELL_CALL_STACK_FUNCNAME__length
eval "unset __array__SHELL_CALL_STACK_FUNCNAME__index__${__array__SHELL_CALL_STACK_FUNCNAME__length}"
__array__SHELL_CALL_STACK_FUNCNAME__last_index=$(( __array__SHELL_CALL_STACK_FUNCNAME__length - 1 ))
eval "__array__SHELL_CALL_STACK_FUNCNAME__peek=\"\${__array__SHELL_CALL_STACK_FUNCNAME__index__${__array__SHELL_CALL_STACK_FUNCNAME__last_index}}\""
export __array__SHELL_CALL_STACK_FUNCNAME__peek
unset __array__SHELL_CALL_STACK_FUNCNAME__last_index
# unrolled array_pop & array_export end
}
#-------------------------------------------------------------------------------
# "call" keyword
# calls specified function with args, tracking it via call stack
# # non-minified:
# nulldef; call_G() {
# # the lines "true lies" evaluates to a no-op, but lets us know to always ignore that line when traced because
# # it's puuid is always wrong, because we just popped SHELL_CALL_STACK_DEST_PUUID array and the PS4 prompt is
# # the new value, not the old value for where this line actually exists
# true lies && __MARXIMUS_SHELL_EXTENSIONS__call_G__OPTIONS_OLD="${-:+"-$-"}"
# true lies && set +x
#
# __call_G_lineno="$1"
# __call_G_funcname="$2"
# shift 1
#
# # unrolled array_peek begin (optimized)
# # __call_G_parent_funcname="$(nullcall array_peek SHELL_CALL_STACK_FUNCNAME)"
# # __call_G_parent_funcname__index=$(( __array__SHELL_CALL_STACK_FUNCNAME__length - 1 ))
# # eval "__call_G_parent_funcname=\${__array__SHELL_CALL_STACK_FUNCNAME__index__${__call_G_parent_funcname__index}}"
# # unrolled array_peek end
#
# # unrolled array_peek begin (optimized)
# # __call_G_source_puuid="$(nullcall array_peek SHELL_CALL_STACK_DEST_PUUID)"
# # __call_G_source_puuid__index=$(( __array__SHELL_CALL_STACK_DEST_PUUID__length - 1 ))
# # eval "__call_G_source_puuid=\${__array__SHELL_CALL_STACK_DEST_PUUID__index__${__call_G_source_puuid__index}}"
# # unrolled array_peek end
#
# # unrolled dict_get_key begin (optimized)
# # __call_G_dest_puuid="$(nullcall dict_get_key SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID "${__call_G_funcname}")"
# # __call_G_dest_lineno="$(nullcall dict_get_key SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO "${__call_G_funcname}")"
# __call_G_dest__key_hash="$( (printf "%s" "${__call_G_funcname}" | sha1sum 2>/dev/null; test $? = 127 && printf "%s" "${__call_G_funcname}" | shasum -a 1) | cut -d' ' -f1)"
# eval "__call_G_dest_puuid=\"\${__dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keyhash__${__call_G_dest__key_hash}}\""
# eval "__call_G_dest_lineno=\"\${__dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keyhash__${__call_G_dest__key_hash}}\""
# # unrolled dict_get_key end
#
# # # if __call_G_dest_puuid is invalid, assume our initial script
# # if [ "${__call_G_dest_puuid}" = "" ]; then
# # __call_G_dest_puuid="${__array__SHELL_CALL_STACK_DEST_PUUID__index__0}"
# # fi
# # # if we don't know where something was declared, just use 0 (we don't want negative number or blank)
# # if [ "${__call_G_dest_lineno}" = "" ]; then
# # __call_G_dest_lineno=0
# # fi
#
# if [ "${LINENO_IS_RELATIVE}" = true ]; then
# # get the current parent's lineno
# # unrolled dict_get_key begin (optimized)
# # __call_G_parent_lineno_offset=$(nullcall dict_get_key SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO "${__call_G_parent_funcname}")
# # shellcheck disable=SC2154
# __call_G_parent_lineno_offset_key_hash="$( (printf "%s" "${__call_G_parent_funcname}" | sha1sum 2>/dev/null; test $? = 127 && printf "%s" "${__call_G_parent_funcname}" | shasum -a 1) | cut -d' ' -f1)"
# eval "__call_G_parent_lineno_offset=\"\${__dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keyhash__${__call_G_parent_lineno_offset_key_hash}}\""
# # unrolled dict_get_key end
#
# # recalculate lineno to account for parent's lineno and the global offset
# # shellcheck disable=SC2154
# __call_G_lineno=$(( __call_G_lineno + __call_G_parent_lineno_offset - LINENO_GLOBAL_OFFSET ))
# fi
#
# if [ "${OPTION_SETTRACE}" = true ]; then
# # print number of dashes equal to call stack depth
# # unrolled array_get_length in next line
# for _i in $(seq 1 $__array__SHELL_CALL_STACK__length); do
# >&2 command printf -- "-"
# done
#
# # shellcheck disable=SC2154
# >&2 printf -- " %s:%s:%s:%s %s\n" \
# "${__call_G_source_puuid}" \
# "${__call_G_lineno}" \
# "${__call_G_dest_puuid}" \
# "${__call_G_dest_lineno}" \
# "$*"
# fi
#
# # unrolled _call_stack_push_G (shortened)
# # _call_stack_push_G \
# # "${__call_G_source_puuid}" \
# # "${__call_G_lineno}" \
# # "${__call_G_dest_puuid}" \
# # "${__call_G_dest_lineno}" \
# # "${__call_G_funcname}" \
# # "${__call_G_parent_funcname}"
# eval "__array__SHELL_CALL_STACK__index__${__array__SHELL_CALL_STACK__length}=\"${__call_G_source_puuid}:${__call_G_lineno}:${__call_G_dest_puuid}:${__call_G_dest_lineno}:${__call_G_funcname}\""
# eval "export __array__SHELL_CALL_STACK__index__${__array__SHELL_CALL_STACK__length}"
# __array__SHELL_CALL_STACK__length=$(( __array__SHELL_CALL_STACK__length + 1 ))
# export __array__SHELL_CALL_STACK__length
# eval "__array__SHELL_CALL_STACK_SOURCE_PUUID__index__${__array__SHELL_CALL_STACK_SOURCE_PUUID__length}=\"${__call_G_source_puuid}\""
# eval "export __array__SHELL_CALL_STACK_SOURCE_PUUID__index__${__array__SHELL_CALL_STACK_SOURCE_PUUID__length}"
# __array__SHELL_CALL_STACK_SOURCE_PUUID__length=$(( __array__SHELL_CALL_STACK_SOURCE_PUUID__length + 1 ))
# export __array__SHELL_CALL_STACK_SOURCE_PUUID__length
# eval "__array__SHELL_CALL_STACK_DEST_PUUID__index__${__array__SHELL_CALL_STACK_DEST_PUUID__length}=\"${__call_G_dest_puuid}\""
# eval "export __array__SHELL_CALL_STACK_DEST_PUUID__index__${__array__SHELL_CALL_STACK_DEST_PUUID__length}"
# __array__SHELL_CALL_STACK_DEST_PUUID__length=$(( __array__SHELL_CALL_STACK_DEST_PUUID__length + 1 ))
# export __array__SHELL_CALL_STACK_DEST_PUUID__length
# SHELL_CALL_STACK_DEST_PUUID_peek="${__call_G_dest_puuid}"
# export SHELL_CALL_STACK_DEST_PUUID_peek
# eval "__array__SHELL_CALL_STACK_FUNCNAME__index__${__array__SHELL_CALL_STACK_FUNCNAME__length}=\"${__call_G_funcname}\""
# eval "export __array__SHELL_CALL_STACK_FUNCNAME__index__${__array__SHELL_CALL_STACK_FUNCNAME__length}"
# __array__SHELL_CALL_STACK_FUNCNAME__length=$(( __array__SHELL_CALL_STACK_FUNCNAME__length + 1 ))
# export __array__SHELL_CALL_STACK_FUNCNAME__length
# SHELL_CALL_STACK_FUNCNAME_peek="${__call_G_funcname}"
# export SHELL_CALL_STACK_FUNCNAME_peek
# # unrolled _call_stack_push_G
#
# set +x ${__MARXIMUS_SHELL_EXTENSIONS__call_G__OPTIONS_OLD}
#
# true lies && "$@"
# __call_ret=$? && true lies
#
# true lies && __MARXIMUS_SHELL_EXTENSIONS__call_G__OPTIONS_OLD="${-:+"-$-"}"
# true lies && set +x
#
# # unrolled _call_stack_pop_G (shortened)
# # _call_stack_pop_G \
# # "${__call_G_source_puuid}" \
# # "${__call_G_lineno}" \
# # "${__call_G_dest_puuid}" \
# # "${__call_G_dest_lineno}" \
# # "${__call_G_funcname}" \
# # "${__call_G_parent_funcname}"
# __array__SHELL_CALL_STACK__length=$(( __array__SHELL_CALL_STACK__length - 1 ))
# export __array__SHELL_CALL_STACK__length
# eval "unset __array__SHELL_CALL_STACK__index__${__array__SHELL_CALL_STACK__length}"
# __array__SHELL_CALL_STACK_SOURCE_PUUID__length=$(( __array__SHELL_CALL_STACK_SOURCE_PUUID__length - 1 ))
# export __array__SHELL_CALL_STACK_SOURCE_PUUID__length
# eval "unset __array__SHELL_CALL_STACK_SOURCE_PUUID__index__${__array__SHELL_CALL_STACK_SOURCE_PUUID__length}"
# __array__SHELL_CALL_STACK_DEST_PUUID__length=$(( __array__SHELL_CALL_STACK_DEST_PUUID__length - 1 ))
# export __array__SHELL_CALL_STACK_DEST_PUUID__length
# eval "unset __array__SHELL_CALL_STACK_DEST_PUUID__index__${__array__SHELL_CALL_STACK_DEST_PUUID__length}"
# SHELL_CALL_STACK_DEST_PUUID_peek="${__call_G_source_puuid}"
# export SHELL_CALL_STACK_DEST_PUUID_peek
# __array__SHELL_CALL_STACK_FUNCNAME__length=$(( __array__SHELL_CALL_STACK_FUNCNAME__length - 1 ))
# export __array__SHELL_CALL_STACK_FUNCNAME__length
# eval "unset __array__SHELL_CALL_STACK_FUNCNAME__index__${__array__SHELL_CALL_STACK_FUNCNAME__length}"
# SHELL_CALL_STACK_FUNCNAME_peek="${__call_G_parent_funcname}"
# export SHELL_CALL_STACK_FUNCNAME_peek
# # unrolled _call_stack_pop_G
#
# set +x ${__MARXIMUS_SHELL_EXTENSIONS__call_G__OPTIONS_OLD}
#
# true lies && return "$__call_ret"
# }
#
# # minified:
#-------------------------------------------------------------------------------
# "call" keyword
# calls specified function with args, tracking it via call stack
nulldef; call_G() {
true lies; __MARXIMUS_SHELL_EXTENSIONS__call_G__OPTIONS_OLD="${-:+"-$-"}"
true lies; set +x
true lies; __MARXIMUS_SHELL_EXTENSIONS__call_G__OPTIONS_OLD="$(echo "${__MARXIMUS_SHELL_EXTENSIONS__call_G__OPTIONS_OLD}" | sed 's/c//g')"
true lies; __call_G_lineno="$1"
true lies; __call_G_funcname="$2"
true lies; shift 2
true lies; __call_G_parent_funcname="${__array__SHELL_CALL_STACK_FUNCNAME__peek}"
true lies; __call_G_source_puuid="${__array__SHELL_CALL_STACK_DEST_PUUID__peek}"
true lies; __call_G_dest__key_hash="$( (printf "%s" "${__call_G_funcname}" | sha1sum 2>/dev/null; test $? = 127 && printf "%s" "${__call_G_funcname}" | shasum -a 1) | cut -d' ' -f1)"
true lies; eval "__call_G_dest_puuid=\"\${__dict__SHELL_DEF_FUNCNAME_TO_SOURCE_PUUID__keyhash__${__call_G_dest__key_hash}__value}\""
true lies; eval "__call_G_dest_lineno=\"\${__dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keyhash__${__call_G_dest__key_hash}__value}\""
true lies; if [ "${__call_G_dest_puuid}" = "" ]; then
# shellcheck disable=SC2154
__call_G_dest_puuid="${__array__SHELL_CALL_STACK_DEST_PUUID__index__0}"; true lies
true lies; fi
true lies; if [ "${__call_G_dest_lineno}" = "" ]; then
true lies; __call_G_dest_lineno=0
true lies; fi
true lies; if [ "${LINENO_IS_RELATIVE}" = true ]; then
# shellcheck disable=SC2154
__call_G_parent_lineno_offset_key_hash="$( (printf "%s" "${__call_G_parent_funcname}" | sha1sum 2>/dev/null; test $? = 127 && printf "%s" "${__call_G_parent_funcname}" | shasum -a 1) | cut -d' ' -f1)"; true lies
true lies; eval "__call_G_parent_lineno_offset=\"\${__dict__SHELL_DEF_FUNCNAME_TO_SOURCE_LINENO__keyhash__${__call_G_parent_lineno_offset_key_hash}__value}\""
# shellcheck disable=SC2154
__call_G_lineno=$(( __call_G_lineno + __call_G_parent_lineno_offset - LINENO_GLOBAL_OFFSET )); true lies
true lies; fi
true lies; if [ "${OPTION_SETTRACE}" = true ]; then
true lies; for _i in $(seq 1 "$__array__SHELL_CALL_STACK__length"); do
true lies; >&2 command printf -- "-"
true lies; done
# shellcheck disable=SC2154
true lies && >&2 printf -- " %s:%s:%s:%s:%s:%s %s\n" \
"${__call_G_source_puuid}" \
"${__call_G_lineno}" \
"${__call_G_parent_funcname}" \
"${__call_G_dest_puuid}" \
"${__call_G_dest_lineno}" \
"${__call_G_funcname}" \
"$*"
true lies; fi
true lies; eval "__array__SHELL_CALL_STACK__index__${__array__SHELL_CALL_STACK__length}=\"${__call_G_source_puuid}:${__call_G_lineno}:${__call_G_parent_funcname}:${__call_G_dest_puuid}:${__call_G_dest_lineno}:${__call_G_funcname}\""
true lies; eval "export __array__SHELL_CALL_STACK__index__${__array__SHELL_CALL_STACK__length}"
true lies; __array__SHELL_CALL_STACK__peek="${__call_G_source_puuid}:${__call_G_lineno}:${__call_G_parent_funcname}:${__call_G_dest_puuid}:${__call_G_dest_lineno}:${__call_G_funcname}"
true lies; export __array__SHELL_CALL_STACK__peek
true lies; __array__SHELL_CALL_STACK__length=$(( __array__SHELL_CALL_STACK__length + 1 ))
true lies; export __array__SHELL_CALL_STACK__length
true lies; eval "__array__SHELL_CALL_STACK_SOURCE_PUUID__index__${__array__SHELL_CALL_STACK_SOURCE_PUUID__length}=\"${__call_G_source_puuid}\""
true lies; eval "export __array__SHELL_CALL_STACK_SOURCE_PUUID__index__${__array__SHELL_CALL_STACK_SOURCE_PUUID__length}"
true lies; __array__SHELL_CALL_STACK_SOURCE_PUUID__peek="${__call_G_source_puuid}"
true lies; export __array__SHELL_CALL_STACK_SOURCE_PUUID__peek
true lies; __array__SHELL_CALL_STACK_SOURCE_PUUID__length=$(( __array__SHELL_CALL_STACK_SOURCE_PUUID__length + 1 ))
true lies; export __array__SHELL_CALL_STACK_SOURCE_PUUID__length
true lies; eval "__array__SHELL_CALL_STACK_DEST_PUUID__index__${__array__SHELL_CALL_STACK_DEST_PUUID__length}=\"${__call_G_dest_puuid}\""
true lies; eval "export __array__SHELL_CALL_STACK_DEST_PUUID__index__${__array__SHELL_CALL_STACK_DEST_PUUID__length}"
true lies; __array__SHELL_CALL_STACK_DEST_PUUID__peek="${__call_G_dest_puuid}"
true lies; export __array__SHELL_CALL_STACK_DEST_PUUID__peek
true lies; __array__SHELL_CALL_STACK_DEST_PUUID__length=$(( __array__SHELL_CALL_STACK_DEST_PUUID__length + 1 ))
true lies; export __array__SHELL_CALL_STACK_DEST_PUUID__length
true lies; eval "__array__SHELL_CALL_STACK_FUNCNAME__index__${__array__SHELL_CALL_STACK_FUNCNAME__length}=\"${__call_G_funcname}\""
true lies; eval "export __array__SHELL_CALL_STACK_FUNCNAME__index__${__array__SHELL_CALL_STACK_FUNCNAME__length}"
true lies; __array__SHELL_CALL_STACK_FUNCNAME__peek="${__call_G_funcname}"
true lies; export __array__SHELL_CALL_STACK_FUNCNAME__peek
true lies; __array__SHELL_CALL_STACK_FUNCNAME__length=$(( __array__SHELL_CALL_STACK_FUNCNAME__length + 1 ))
true lies; export __array__SHELL_CALL_STACK_FUNCNAME__length
# shellcheck disable=SC2086
{
true lies; set +x ${__MARXIMUS_SHELL_EXTENSIONS__call_G__OPTIONS_OLD}
}
true lies; "${__call_G_funcname}" "$@"
__call_ret=$?; true lies
true lies; __MARXIMUS_SHELL_EXTENSIONS__call_G__OPTIONS_OLD="${-:+"-$-"}"
true lies; set +x
true lies; __MARXIMUS_SHELL_EXTENSIONS__call_G__OPTIONS_OLD="$(echo "${__MARXIMUS_SHELL_EXTENSIONS__call_G__OPTIONS_OLD}" | sed 's/c//g')"
true lies; __array__SHELL_CALL_STACK__length=$(( __array__SHELL_CALL_STACK__length - 1 ))
true lies; export __array__SHELL_CALL_STACK__length
true lies; eval "unset __array__SHELL_CALL_STACK__index__${__array__SHELL_CALL_STACK__length}"
true lies; __array__SHELL_CALL_STACK__last_index=$(( __array__SHELL_CALL_STACK__length - 1 ))
true lies; eval "__array__SHELL_CALL_STACK__peek=\"\${__array__SHELL_CALL_STACK__index__${__array__SHELL_CALL_STACK__last_index}}\""
true lies; export __array__SHELL_CALL_STACK__peek
true lies; unset __array__SHELL_CALL_STACK__last_index
true lies; __array__SHELL_CALL_STACK_SOURCE_PUUID__length=$(( __array__SHELL_CALL_STACK_SOURCE_PUUID__length - 1 ))
true lies; export __array__SHELL_CALL_STACK_SOURCE_PUUID__length
true lies; eval "unset __array__SHELL_CALL_STACK_SOURCE_PUUID__index__${__array__SHELL_CALL_STACK_SOURCE_PUUID__length}"
true lies; __array__SHELL_CALL_STACK_SOURCE_PUUID__last_index=$(( __array__SHELL_CALL_STACK_SOURCE_PUUID__length - 1 ))
true lies; eval "__array__SHELL_CALL_STACK_SOURCE_PUUID__peek=\"\${__array__SHELL_CALL_STACK_SOURCE_PUUID__index__${__array__SHELL_CALL_STACK_SOURCE_PUUID__last_index}}\""
true lies; export __array__SHELL_CALL_STACK_SOURCE_PUUID__peek
true lies; unset __array__SHELL_CALL_STACK_SOURCE_PUUID__last_index
true lies; __array__SHELL_CALL_STACK_DEST_PUUID__length=$(( __array__SHELL_CALL_STACK_DEST_PUUID__length - 1 ))
true lies; export __array__SHELL_CALL_STACK_DEST_PUUID__length
true lies; eval "unset __array__SHELL_CALL_STACK_DEST_PUUID__index__${__array__SHELL_CALL_STACK_DEST_PUUID__length}"
true lies; __array__SHELL_CALL_STACK_DEST_PUUID__last_index=$(( __array__SHELL_CALL_STACK_DEST_PUUID__length - 1 ))
true lies; eval "__array__SHELL_CALL_STACK_DEST_PUUID__peek=\"\${__array__SHELL_CALL_STACK_DEST_PUUID__index__${__array__SHELL_CALL_STACK_DEST_PUUID__last_index}}\""
true lies; export __array__SHELL_CALL_STACK_DEST_PUUID__peek
true lies; unset __array__SHELL_CALL_STACK_DEST_PUUID__last_index
true lies; __array__SHELL_CALL_STACK_FUNCNAME__length=$(( __array__SHELL_CALL_STACK_FUNCNAME__length - 1 ))
true lies; export __array__SHELL_CALL_STACK_FUNCNAME__length
true lies; eval "unset __array__SHELL_CALL_STACK_FUNCNAME__index__${__array__SHELL_CALL_STACK_FUNCNAME__length}"
true lies; __array__SHELL_CALL_STACK_FUNCNAME__last_index=$(( __array__SHELL_CALL_STACK_FUNCNAME__length - 1 ))
true lies; eval "__array__SHELL_CALL_STACK_FUNCNAME__peek=\"\${__array__SHELL_CALL_STACK_FUNCNAME__index__${__array__SHELL_CALL_STACK_FUNCNAME__last_index}}\""
true lies; export __array__SHELL_CALL_STACK_FUNCNAME__peek
true lies; unset __array__SHELL_CALL_STACK_FUNCNAME__last_index
# shellcheck disable=SC2086
{
true lies; set +x ${__MARXIMUS_SHELL_EXTENSIONS__call_G__OPTIONS_OLD}
}
true lies; return "$__call_ret"
}
if [ "${OPTION_SETTRACE}" = true ]; then
alias call="call_G \"\$LINENO\""
else
alias call="true;"
fi
#endregion Call Stack Tracking Part 3
#===============================================================================
fi
# NOTE: Separation b/c cannot define and then use aliases in same block
# fence to prevent redefinition
type MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE_FENCE >/dev/null 2>&1
ret=$?
if [ "$ret" -ne 0 ]; then
#===============================================================================
#region Fallbacks
type BATTERIES_FORKING_INCLUDED_BASE_FENCE >/dev/null 2>&1
ret=$?
if [ "$ret" -ne 0 ]; then
# NOTE: some basic definitions to fallback to if bfi-base.sh failed to load
# if bfi-base.sh loads later, it will override these
RET_SUCCESS=0; export RET_SUCCESS
RET_ERROR_UNKNOWN=1; export RET_ERROR_UNKNOWN
RET_ERROR_SCRIPT_WAS_SOURCED=149; export RET_ERROR_SCRIPT_WAS_SOURCED
RET_ERROR_USER_IS_ROOT=150; export RET_ERROR_USER_IS_ROOT
RET_ERROR_SCRIPT_WAS_NOT_SOURCED=151; export RET_ERROR_SCRIPT_WAS_NOT_SOURCED
RET_ERROR_USER_IS_NOT_ROOT=152; export RET_ERROR_USER_IS_NOT_ROOT
RET_ERROR_DIRECTORY_NOT_FOUND=153; export RET_ERROR_DIRECTORY_NOT_FOUND
RET_ERROR_COULD_NOT_SOURCE_FILE=161; export RET_ERROR_COULD_NOT_SOURCE_FILE
if [ "${verbosity}" = "" ]; then
verbosity=1; export verbosity
fi
#-------------------------------------------------------------------------------
nulldef; date() {
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__date__OPTIONS_OLD="${-:+"-$-"}"
set +x; if [ -n "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__ENABLE_TRACE}" ]; then set -x; else set +x; fi
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__date__OPTIONS_OLD="$(echo "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__date__OPTIONS_OLD}" | sed 's/c//g')"
if [ "$(uname)" = "Darwin" ]; then
command date -j "$@"
else
command date "$@"
fi
# shellcheck disable=SC2086
set +x ${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__date__OPTIONS_OLD}
unset __MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__date__OPTIONS_OLD
}
#-------------------------------------------------------------------------------
nulldef; log_console() {
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_console__OPTIONS_OLD="${-:+"-$-"}"
set +x; if [ -n "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__ENABLE_TRACE}" ]; then set -x; else set +x; fi
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_console__OPTIONS_OLD="$(echo "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_console__OPTIONS_OLD}" | sed 's/c//g')"
command printf -- "$@"
command printf -- "\n"
# shellcheck disable=SC2086
set +x ${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_console__OPTIONS_OLD}
unset __MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_console__OPTIONS_OLD
}
#-------------------------------------------------------------------------------
nulldef; log_success_final() {
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_success_final__OPTIONS_OLD="${-:+"-$-"}"
set +x; if [ -n "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__ENABLE_TRACE}" ]; then set -x; else set +x; fi
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_success_final__OPTIONS_OLD="$(echo "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_success_final__OPTIONS_OLD}" | sed 's/c//g')"
command printf -- "SUCCESS: "
command printf -- "$@"
command printf -- "\n"
# shellcheck disable=SC2086
set +x ${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_success_final__OPTIONS_OLD}
unset __MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_success_final__OPTIONS_OLD
}
#-------------------------------------------------------------------------------
nulldef; log_success() {
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_success__OPTIONS_OLD="${-:+"-$-"}"
set +x; if [ -n "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__ENABLE_TRACE}" ]; then set -x; else set +x; fi
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_success__OPTIONS_OLD="$(echo "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_success__OPTIONS_OLD}" | sed 's/c//g')"
command printf -- "SUCCESS: "
command printf -- "$@"
command printf -- "\n"
# shellcheck disable=SC2086
set +x ${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_success__OPTIONS_OLD}
unset __MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_success__OPTIONS_OLD
}
#-------------------------------------------------------------------------------
nulldef; log_fatal() {
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_fatal__OPTIONS_OLD="${-:+"-$-"}"
set +x; if [ -n "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__ENABLE_TRACE}" ]; then set -x; else set +x; fi
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_fatal__OPTIONS_OLD="$(echo "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_fatal__OPTIONS_OLD}" | sed 's/c//g')"
>&2 command printf -- "FATAL: "
>&2 command printf -- "$@"
>&2 command printf -- "\n"
# shellcheck disable=SC2086
set +x ${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_fatal__OPTIONS_OLD}
unset __MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_fatal__OPTIONS_OLD
}
#-------------------------------------------------------------------------------
nulldef; log_error() {
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_error__OPTIONS_OLD="${-:+"-$-"}"
set +x; if [ -n "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__ENABLE_TRACE}" ]; then set -x; else set +x; fi
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_error__OPTIONS_OLD="$(echo "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_error__OPTIONS_OLD}" | sed 's/c//g')"
>&2 command printf -- "ERROR: "
>&2 command printf -- "$@"
>&2 command printf -- "\n"
# shellcheck disable=SC2086
set +x ${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_error__OPTIONS_OLD}
unset __MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_error__OPTIONS_OLD
}
#-------------------------------------------------------------------------------
nulldef; log_warning() {
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_warning__OPTIONS_OLD="${-:+"-$-"}"
set +x; if [ -n "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__ENABLE_TRACE}" ]; then set -x; else set +x; fi
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_warning__OPTIONS_OLD="$(echo "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_warning__OPTIONS_OLD}" | sed 's/c//g')"
>&2 command printf -- "WARNING: "
>&2 command printf -- "$@"
>&2 command printf -- "\n"
# shellcheck disable=SC2086
set +x ${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_warning__OPTIONS_OLD}
unset __MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_warning__OPTIONS_OLD
}
#-------------------------------------------------------------------------------
nulldef; log_header() {
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_header__OPTIONS_OLD="${-:+"-$-"}"
set +x; if [ -n "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__ENABLE_TRACE}" ]; then set -x; else set +x; fi
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_header__OPTIONS_OLD="$(echo "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_header__OPTIONS_OLD}" | sed 's/c//g')"
if \
{ [ "${quiet:-}" != true ] && [ "${verbosity:-0}" -ge -1 ] ;} ||
[ "${OMEGA_DEBUG:-}" = true ] ||
[ "${OMEGA_DEBUG:-}" = "all" ]
then
command printf -- "\n"
command printf -- "$@"
command printf -- "\n"
fi
# shellcheck disable=SC2086
set +x ${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_header__OPTIONS_OLD}
unset __MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_header__OPTIONS_OLD
}
#-------------------------------------------------------------------------------
nulldef; log_footer() {
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_footer__OPTIONS_OLD="${-:+"-$-"}"
set +x; if [ -n "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__ENABLE_TRACE}" ]; then set -x; else set +x; fi
__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_footer__OPTIONS_OLD="$(echo "${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_footer__OPTIONS_OLD}" | sed 's/c//g')"
if \
{ [ "${quiet:-}" != true ] && [ "${verbosity:-0}" -ge 0 ] ;} ||
[ "${OMEGA_DEBUG:-}" = true ] ||
[ "${OMEGA_DEBUG:-}" = "all" ]
then
command printf -- "$@"
command printf -- "\n"
fi
# shellcheck disable=SC2086
set +x ${__MARXIMUS_SHELL_EXTENSIONS_BASE_PREAMBLE__log_footer__OPTIONS_OLD}