-
Notifications
You must be signed in to change notification settings - Fork 1
/
_anchor.bat
executable file
·1524 lines (1235 loc) · 46.8 KB
/
_anchor.bat
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
@rem(){ :;};@rem echo '
@echo off
@goto b
' > /dev/null 2>&1 ;
rem(){ :;};rem
if [[ "$1" == 'ubAnchorSelfTestOnly' ]]
then
echo PASS-BASH
exit
fi
if [[ "$1" == 'MSWselfReinterpret' ]]
then
shift
# ATTENTION: DANGER: Not yet implemented. Comment to allow continuation production use.
exit 1
fi
# WARNING: MSW compatible anchor batch script. This should NOT be required for all Ubiquitous Bash functions.
# Rather, MSW compatble anchor batch scripts should ONLY be needed to integrate with legacy programs which are
# required for interoperability, unable to be recompiled from source, and unusually unable to be controlled
# from native UNIX environments.
# DANGER: Beware the MSW platform has historically been less stable, standalone, and/or reliable through the year 2020.
# DANGER: Beware this must behave correctly under BOTH MSW and native UNIX platforms.
#Universal debugging filesystem.
_user_log_anchor() {
# DANGER Do NOT create automatically, or reference any existing directory!
! [[ -d "$HOME"/.ubcore/userlog ]] && cat - > /dev/null 2>&1 && return 0
#Terminal session may be used - the sessionid may be set through .bashrc/.ubcorerc .
if [[ "$sessionid" != "" ]]
then
cat - >> "$HOME"/.ubcore/userlog/a-"$sessionid".log
return 0
fi
cat - >> "$HOME"/.ubcore/userlog/a-undef.log
return 0
}
#Cyan. Harmless status messages.
_messagePlain_nominal() {
echo -e -n '\E[0;36m '
echo -n "$@"
echo -e -n ' \E[0m'
echo
return 0
}
#Blue. Diagnostic instrumentation.
_messagePlain_probe() {
echo -e -n '\E[0;34m '
echo -n "$@"
echo -e -n ' \E[0m'
echo
return 0
}
#Blue. Diagnostic instrumentation.
_messagePlain_probe_expr() {
echo -e -n '\E[0;34m '
echo -e -n "$@"
echo -e -n ' \E[0m'
echo
return 0
}
#Green. Working as expected.
_messagePlain_good() {
echo -e -n '\E[0;32m '
echo -n "$@"
echo -e -n ' \E[0m'
echo
return 0
}
#Yellow. May or may not be a problem.
_messagePlain_warn() {
echo -e -n '\E[1;33m '
echo -n "$@"
echo -e -n ' \E[0m'
echo
return 0
}
#Red. Will result in missing functionality, reduced performance, etc, but not necessarily program failure overall.
_messagePlain_bad() {
echo -e -n '\E[0;31m '
echo -n "$@"
echo -e -n ' \E[0m'
echo
return 0
}
##Parameters
#"--shell", ""
#"--profile"
#"--parent", "--embed", "--return", "--devenv"
#"--call", "--script" "--bypass"
ub_import=
ub_import_param=
ub_import_script=
ub_loginshell=
[[ "${BASH_SOURCE[0]}" != "${0}" ]] && ub_import="true"
([[ "$1" == '--profile' ]] || [[ "$1" == '--script' ]] || [[ "$1" == '--call' ]] || [[ "$1" == '--return' ]] || [[ "$1" == '--devenv' ]] || [[ "$1" == '--shell' ]] || [[ "$1" == '--bypass' ]] || [[ "$1" == '--parent' ]] || [[ "$1" == '--embed' ]]) && ub_import_param="$1" && shift
([[ "$0" == "/bin/bash" ]] || [[ "$0" == "-bash" ]] || [[ "$0" == "/usr/bin/bash" ]] || [[ "$0" == "bash" ]]) && ub_loginshell="true" #Importing ubiquitous bash into a login shell with "~/.bashrc" is the only known cause for "_getScriptAbsoluteLocation" to return a result such as "/bin/bash".
[[ "$ub_import" == "true" ]] && ! [[ "$ub_loginshell" == "true" ]] && ub_import_script="true"
_messagePlain_probe_expr '$0= '"$0"'\n ''$1= '"$1"'\n ''ub_import= '"$ub_import"'\n ''ub_import_param= '"$ub_import_param"'\n ''ub_import_script= '"$ub_import_script"'\n ''ub_loginshell= '"$ub_loginshell" | _user_log_anchor
# DANGER Prohibited import from login shell. Use _setupUbiquitous, call from another script, or manually set importScriptLocation.
# WARNING Import from shell can be detected. Import from script cannot. Asserting that script has been imported is possible. Asserting that script has not been imported is not possible. Users may be protected from interactive mistakes. Script developers are NOT protected.
if [[ "$ub_import_param" == "--profile" ]]
then
([[ "$profileScriptLocation" == "" ]] || [[ "$profileScriptFolder" == "" ]]) && _messagePlain_bad 'import: profile: missing: profileScriptLocation, missing: profileScriptFolder' | _user_log_anchor && return 1
elif ([[ "$ub_import_param" == "--parent" ]] || [[ "$ub_import_param" == "--embed" ]] || [[ "$ub_import_param" == "--return" ]] || [[ "$ub_import_param" == "--devenv" ]])
then
([[ "$scriptAbsoluteLocation" == "" ]] || [[ "$scriptAbsoluteFolder" == "" ]] || [[ "$sessionid" == "" ]]) && _messagePlain_bad 'import: parent: missing: scriptAbsoluteLocation, missing: scriptAbsoluteFolder, missing: sessionid' | _user_log_anchor && return 1
elif [[ "$ub_import_param" == "--call" ]] || [[ "$ub_import_param" == "--script" ]] || [[ "$ub_import_param" == "--bypass" ]] || [[ "$ub_import_param" == "--shell" ]] || ([[ "$ub_import" == "true" ]] && [[ "$ub_import_param" == "" ]])
then
([[ "$importScriptLocation" == "" ]] || [[ "$importScriptFolder" == "" ]]) && _messagePlain_bad 'import: call: missing: importScriptLocation, missing: importScriptFolder' | _user_log_anchor && return 1
elif [[ "$ub_import" != "true" ]] #"--shell", ""
then
_messagePlain_warn 'import: undetected: cannot determine if imported' | _user_log_anchor
true #no problem
else #FAIL, implies [[ "$ub_import" == "true" ]]
_messagePlain_bad 'import: fall: fail' | _user_log_anchor && return 1
exit 1
fi
if [[ "$ub_import_param" == "--profile" ]]
then
ub_import=true
elif ([[ "$ub_import_param" == "--parent" ]] || [[ "$ub_import_param" == "--embed" ]] || [[ "$ub_import_param" == "--return" ]] || [[ "$ub_import_param" == "--devenv" ]]) && [[ "$scriptAbsoluteLocation" != "" ]] && [[ "$scriptAbsoluteFolder" != "" ]] && [[ "$sessionid" != "" ]]
then
ub_import=true
elif [[ "$ub_import_param" == "--call" ]] || [[ "$ub_import_param" == "--script" ]] || [[ "$ub_import_param" == "--bypass" ]] || [[ "$ub_import_param" == "--shell" ]] || ([[ "$ub_import" == "true" ]] && [[ "$ub_import_param" == "" ]])
then
ub_import=true
fi
[[ "$ub_import" != "true" ]] && ub_import_param=
#Critical prerequsites.
_realpath_L() {
if ! _compat_realpath_run -L . > /dev/null 2>&1
then
readlink -f "$@"
return
fi
realpath -L "$@"
}
_realpath_L_s() {
if ! _compat_realpath_run -L . > /dev/null 2>&1
then
readlink -f "$@"
return
fi
realpath -L -s "$@"
}
_getAbsolute_criticalDep() {
! type realpath > /dev/null 2>&1 && return 1
! type readlink > /dev/null 2>&1 && return 1
! type dirname > /dev/null 2>&1 && return 1
#Known issue on Mac. See https://github.com/mirage335/ubiquitous_bash/issues/1 .
! realpath -L . > /dev/null 2>&1 && return 1
return 0
}
! _getAbsolute_criticalDep && exit 1
#####Utilities.
#Retrieves absolute path of current script, while maintaining symlinks, even when "./" would translate with "readlink -f" into something disregarding symlinked components in $PWD.
#However, will dereference symlinks IF the script location itself is a symlink. This is to allow symlinking to scripts to function normally.
#Suitable for allowing scripts to find other scripts they depend on. May look like an ugly hack, but it has proven reliable over the years.
_getScriptAbsoluteLocation() {
if [[ "$0" == "-"* ]]
then
return 1
fi
local absoluteLocation
if [[ (-e $PWD\/$0) && ($0 != "") ]] && [[ "$0" != "/"* ]]
then
absoluteLocation="$PWD"\/"$0"
absoluteLocation=$(_realpath_L_s "$absoluteLocation")
else
absoluteLocation=$(_realpath_L "$0")
fi
if [[ -h "$absoluteLocation" ]]
then
absoluteLocation=$(readlink -f "$absoluteLocation")
absoluteLocation=$(_realpath_L "$absoluteLocation")
fi
echo $absoluteLocation
}
alias getScriptAbsoluteLocation=_getScriptAbsoluteLocation
#Retrieves absolute path of current script, while maintaining symlinks, even when "./" would translate with "readlink -f" into something disregarding symlinked components in $PWD.
#Suitable for allowing scripts to find other scripts they depend on.
_getScriptAbsoluteFolder() {
if [[ "$0" == "-"* ]]
then
return 1
fi
dirname "$(_getScriptAbsoluteLocation)"
}
alias getScriptAbsoluteFolder=_getScriptAbsoluteFolder
#Retrieves absolute path of parameter, while maintaining symlinks, even when "./" would translate with "readlink -f" into something disregarding symlinked components in $PWD.
#Suitable for finding absolute paths, when it is desirable not to interfere with symlink specified folder structure.
_getAbsoluteLocation() {
if [[ "$1" == "-"* ]]
then
return 1
fi
if [[ "$1" == "" ]]
then
echo
return
fi
local absoluteLocation
if [[ (-e $PWD\/$1) && ($1 != "") ]] && [[ "$1" != "/"* ]]
then
absoluteLocation="$PWD"\/"$1"
absoluteLocation=$(_realpath_L_s "$absoluteLocation")
else
absoluteLocation=$(_realpath_L "$1")
fi
echo "$absoluteLocation"
}
alias getAbsoluteLocation=_getAbsoluteLocation
#https://unix.stackexchange.com/questions/27021/how-to-name-a-file-in-the-deepest-level-of-a-directory-tree?answertab=active#tab-top
_filter_lowestPath() {
awk -F'/' 'NF > depth {
depth = NF;
deepest = $0;
}
END {
print deepest;
}'
}
#https://stackoverflow.com/questions/1086907/can-find-or-any-other-tool-search-for-files-breadth-first
_filter_highestPath() {
awk -F'/' '{print "", NF, $F}' | sort -n | awk '{print $2}' | head -n 1
}
_recursion_guard() {
! [[ -e "$1" ]] && return 1
! [[ -s "$1" ]] && return 1
! head --bytes=1 "$1" > /dev/null 2>&1 && return 1
#! type "$1" >/dev/null 2>&1 && return 1
local launchGuardScriptAbsoluteLocation
launchGuardScriptAbsoluteLocation=$(_getScriptAbsoluteLocation)
local launchGuardTestAbsoluteLocation
launchGuardTestAbsoluteLocation=$(_getAbsoluteLocation "$1")
[[ "$launchGuardScriptAbsoluteLocation" == "$launchGuardTestAbsoluteLocation" ]] && return 1
return 0
}
#Generates random alphanumeric characters, default length 18.
_uid() {
local uidLength
! [[ -z "$1" ]] && uidLength="$1" || uidLength=18
cat /dev/urandom 2> /dev/null | base64 2> /dev/null | tr -dc 'a-zA-Z0-9' 2> /dev/null | head -c "$uidLength" 2> /dev/null
}
#Demarcate major steps.
_messageNormal() {
echo -e -n '\E[1;32;46m '
echo -n "$@"
echo -e -n ' \E[0m'
echo
return 0
}
#Demarcate major failures.
_messageError() {
echo -e -n '\E[1;33;41m '
echo -n "$@"
echo -e -n ' \E[0m'
echo
return 0
}
#https://stackoverflow.com/questions/4210042/how-to-exclude-a-directory-in-find-command/16595367#16595367
_findAnchor() {
local anchorCurrentSearchDir
anchorCurrentSearchDir="$1"
shift
find -P "$anchorCurrentSearchDir" -not \( -path \*.git\* -prune \) -not \( -path \*_arc\* -prune \) -not \( -path \*_buried\* -prune \) -not \( -path \*_lib\* -prune \) -not \( -path \*_local\* -prune \) -not \( -path \*_local/_index\* -prune \) -not \( -path \*_local/h\* -prune \) -not \( -path \*h_\*/\* -prune \) -not \( -path \*w_\*/\* -prune \) -not \( -path \*../disk\* -prune \) -not \( -path \*../ssh\* -prune \) "$@"
}
#Recursively searches for directories.
_findAnchorSource() {
local anchorCurrentSearchDir
anchorCurrentSearchDir="$1"
shift
local anchorCurrentSearchDirAbsolute
anchorCurrentSearchDirAbsolute=$(_getAbsoluteLocation "$anchorCurrentSearchDir")
_findAnchor "$anchorCurrentSearchDir" -path \*"$anchorSourcePath"
return
}
#Recursively searches for directories.
_findAnchorName() {
local anchorCurrentSearchDir
anchorCurrentSearchDir="$1"
shift
local anchorCurrentSearchDirAbsolute
anchorCurrentSearchDirAbsolute=$(_getAbsoluteLocation "$anchorCurrentSearchDir")
_findAnchor "$anchorCurrentSearchDir" -path \*_index/"$anchorName"
return
}
_check_anchor() {
local anchorCheckLine
while IFS='' read -r anchorCheckLine || [[ -n "$anchorCheckLine" ]]
do
#Conventionally a git submodule for compile purposes only.
[[ "$anchorCheckLine" == *'_lib/ubiquitous_bash/ubiquitous_bash.sh' ]] && continue
[[ "$anchorCheckLine" != *"$anchorSource" ]] && [[ "$anchorCheckLine" != *'ubiquitous_bash.sh' ]] && [[ "$anchorCheckLine" != *"$anchorName" ]] && continue
! _recursion_guard "$anchorCheckLine" && continue
_getAbsoluteLocation "$anchorCheckLine"
done
}
#_safeEcho_anchor "$anchorScriptAbsoluteFolder" | tr -dc 'a-zA-Z0-9.:_-'
_safeEcho_anchor() {
printf '%s' "$1"
shift
[[ "$@" == "" ]] && return 0
local currentArg
for currentArg in "$@"
do
printf '%s' " "
printf '%s' "$currentArg"
done
return 0
}
_launch_anchor() {
_messagePlain_nominal 'anchorName='"$anchorName" | _user_log_anchor
_messagePlain_probe 'anchorScriptAbsoluteLocation='"$anchorScriptAbsoluteLocation" | _user_log_anchor
_messagePlain_probe 'anchorScriptAbsoluteFolder='"$anchorScriptAbsoluteFolder" | _user_log_anchor
_messagePlain_probe 'anchorSourcePath='"$anchorSourcePath" | _user_log_anchor
_messagePlain_probe 'anchorLabName='"$anchorLabName" | _user_log_anchor
_messagePlain_probe 'anchorLabNameAlt='"$anchorLabNameAlt" | _user_log_anchor
_messagePlain_probe 'anchorEntity='"$anchorEntity" | _user_log_anchor
local recursionExec
local anchorParent
# WARNING: What is otherwise considered bad practice may be accepted to reduce substantial MSW/Cygwin inconvenience .
if [[ "$anchorScriptAbsoluteFolder" == '/cygdrive/'* ]]
then
local currentDriveLetter
for currentDriveLetter in {a..z}
do
if [[ "$anchorScriptAbsoluteFolder" == '/cygdrive/'"$currentDriveLetter" ]]
then
recursionExec="$anchorScriptAbsoluteFolder"/"$anchorSource"
if _recursion_guard "$recursionExec"
then
[[ "$ub_import" != "true" ]] && _messagePlain_good 'self: 'bash "$recursionExec" "$anchorName" "$@" | _user_log_anchor
if [[ "$ub_import" != "true" ]]
then
bash "$recursionExec" "$anchorName" "$@"
exit $?
fi
[[ "$ub_import" == "true" ]] && _messagePlain_good 'self: 'bash "$recursionExec" "$ub_import_param" "$anchorName" "$@" | _user_log_anchor
[[ "$ub_import" == "true" ]] && bash "$recursionExec" "$ub_import_param" "$anchorName" "$@"
exit $?
fi
fi
done
fi
if [[ "$anchorScriptAbsoluteFolder" == '/home/user/project' ]] || [[ "$anchorScriptAbsoluteFolder" == /tmp/"$ubiquitiousBashIDnano" ]]
then
recursionExec="$anchorScriptAbsoluteFolder"/"$anchorSource"
if _recursion_guard "$recursionExec"
then
[[ "$ub_import" != "true" ]] && _messagePlain_good 'self: 'bash "$recursionExec" "$anchorName" "$@" | _user_log_anchor
if [[ "$ub_import" != "true" ]]
then
bash "$recursionExec" "$anchorName" "$@"
exit $?
fi
[[ "$ub_import" == "true" ]] && _messagePlain_good 'self: 'bash "$recursionExec" "$ub_import_param" "$anchorName" "$@" | _user_log_anchor
[[ "$ub_import" == "true" ]] && bash "$recursionExec" "$ub_import_param" "$anchorName" "$@"
exit $?
fi
fi
recursionExec="$anchorScriptAbsoluteFolder"/../"$anchorSourcePath"
if _recursion_guard "$recursionExec"
then
[[ "$ub_import" != "true" ]] && _messagePlain_good 'self: 'bash "$recursionExec" "$anchorName" "$@" | _user_log_anchor
if [[ "$ub_import" != "true" ]]
then
bash "$recursionExec" "$anchorName" "$@"
exit $?
fi
[[ "$ub_import" == "true" ]] && _messagePlain_good 'self: 'bash "$recursionExec" "$ub_import_param" "$anchorName" "$@" | _user_log_anchor
[[ "$ub_import" == "true" ]] && bash "$recursionExec" "$ub_import_param" "$anchorName" "$@"
exit $?
fi
#Resolves placement under "$anchorSourcePath"/_index .
recursionExec="$anchorScriptAbsoluteFolder"/../../"$anchorSourcePath"
if _recursion_guard "$recursionExec"
then
[[ "$ub_import" != "true" ]] && _messagePlain_good 'self: 'bash "$recursionExec" "$anchorName" "$@" | _user_log_anchor
if [[ "$ub_import" != "true" ]]
then
bash "$recursionExec" "$anchorName" "$@"
exit $?
fi
[[ "$ub_import" == "true" ]] && _messagePlain_good 'self: 'bash "$recursionExec" "$ub_import_param" "$anchorName" "$@" | _user_log_anchor
[[ "$ub_import" == "true" ]] && bash "$recursionExec" "$ub_import_param" "$anchorName" "$@"
exit $?
fi
anchorDestination=$(_findAnchorSource "$anchorScriptAbsoluteFolder"/.. | _check_anchor | _filter_lowestPath)
if [[ "$anchorDestination" != "" ]]
then
if [[ "$anchorDestination" == *"ubiquitous_bash.sh" ]]
then
_messagePlain_good 'launch: 'bash "$anchorDestination" "$ub_import_param" "$anchorName" "$@" | _user_log_anchor
if [[ "$ub_import" != "true" ]]
then
bash "$anchorDestination" "$anchorName" "$@"
exit $?
fi
[[ "$ub_import" == "true" ]] && bash "$anchorDestination" "$ub_import_param" "$anchorName" "$@"
exit $?
fi
_messagePlain_good 'launch: 'bash "$anchorDestination" "$ub_import_param" "$@" | _user_log_anchor
[[ "$ub_import" != "true" ]] && bash "$anchorDestination" "$@"
[[ "$ub_import" != "true" ]] && exit $?
[[ "$ub_import" == "true" ]] && bash "$anchorDestination" "$ub_import_param" "$@"
exit $?
fi
anchorParent=$(_getAbsoluteLocation "$anchorScriptAbsoluteFolder"/../..)
_messagePlain_probe 'anchorParent='"$anchorParent" | _user_log_anchor
if [[ "$anchorScriptAbsoluteFolder" == *"_local/_index" ]]
then
_messagePlain_probe 'detected: parent: _local/_index' | _user_log_anchor
anchorDestination=$(_findAnchorName "$anchorParent" | _check_anchor | _filter_highestPath)
if [[ "$anchorDestination" != "" ]]
then
_messagePlain_probe 'anchorDestination='"$anchorDestination" | _user_log_anchor
_messagePlain_good 'launch: 'bash "$anchorDestination" "$ub_import_param" "$@" | _user_log_anchor
[[ "$ub_import" != "true" ]] && bash "$anchorDestination" "$@"
[[ "$ub_import" != "true" ]] && exit $?
[[ "$ub_import" == "true" ]] && bash "$anchorDestination" "$ub_import_param" "$anchorName" "$@"
exit $?
fi
fi
recursionExec="$HOME"/core/infrastructure/vm/"$anchorSourcePath"
if _recursion_guard "$recursionExec"
then
[[ "$ub_import" != "true" ]] && _messagePlain_good 'launch: 'bash "$recursionExec" "$anchorName" "$@" | _user_log_anchor
if [[ "$ub_import" != "true" ]]
then
bash "$recursionExec" "$anchorName" "$@"
exit $?
fi
[[ "$ub_import" == "true" ]] && _messagePlain_good 'launch: 'bash "$recursionExec" "$ub_import_param" "$anchorName" "$@" | _user_log_anchor
[[ "$ub_import" == "true" ]] && bash "$recursionExec" "$ub_import_param" "$anchorName" "$@"
exit $?
fi
recursionExec="$HOME"/core/extra/infrastructure/vm/"$anchorSourcePath"
if _recursion_guard "$recursionExec"
then
[[ "$ub_import" != "true" ]] && _messagePlain_good 'launch: 'bash "$recursionExec" "$anchorName" "$@" | _user_log_anchor
if [[ "$ub_import" != "true" ]]
then
bash "$recursionExec" "$anchorName" "$@"
exit $?
fi
[[ "$ub_import" == "true" ]] && _messagePlain_good 'launch: 'bash "$recursionExec" "$ub_import_param" "$anchorName" "$@" | _user_log_anchor
[[ "$ub_import" == "true" ]] && bash "$recursionExec" "$ub_import_param" "$anchorName" "$@"
exit $?
fi
recursionExec="$HOME"/core/installations/"$anchorSourcePath"
if _recursion_guard "$recursionExec"
then
[[ "$ub_import" != "true" ]] && _messagePlain_good 'launch: 'bash "$recursionExec" "$anchorName" "$@" | _user_log_anchor
if [[ "$ub_import" != "true" ]]
then
bash "$recursionExec" "$anchorName" "$@"
exit $?
fi
[[ "$ub_import" == "true" ]] && _messagePlain_good 'launch: 'bash "$recursionExec" "$ub_import_param" "$anchorName" "$@" | _user_log_anchor
[[ "$ub_import" == "true" ]] && bash "$recursionExec" "$ub_import_param" "$anchorName" "$@"
exit $?
fi
recursionExec="$HOME"/core/extra/installations/"$anchorSourcePath"
if _recursion_guard "$recursionExec"
then
[[ "$ub_import" != "true" ]] && _messagePlain_good 'launch: 'bash "$recursionExec" "$anchorName" "$@" | _user_log_anchor
if [[ "$ub_import" != "true" ]]
then
bash "$recursionExec" "$anchorName" "$@"
exit $?
fi
[[ "$ub_import" == "true" ]] && _messagePlain_good 'launch: 'bash "$recursionExec" "$ub_import_param" "$anchorName" "$@" | _user_log_anchor
[[ "$ub_import" == "true" ]] && bash "$recursionExec" "$ub_import_param" "$anchorName" "$@"
exit $?
fi
recursionExec="$HOME"/core/lab/"$anchorEntity""$anchorLabName"/_index/"$anchorName"
if _recursion_guard "$recursionExec"
then
[[ "$ub_import" != "true" ]] && _messagePlain_good 'reference: 'bash "$recursionExec" "$@" | _user_log_anchor
if [[ "$ub_import" != "true" ]]
then
bash "$recursionExec" "$@"
exit $?
fi
[[ "$ub_import" == "true" ]] && _messagePlain_good 'reference: 'bash "$recursionExec" "$ub_import_param" "$@" | _user_log_anchor
[[ "$ub_import" == "true" ]] && bash "$recursionExec" "$ub_import_param" "$@"
exit $?
fi
recursionExec="$HOME"/core/extra/lab/"$anchorEntity""$anchorLabName"/_index/"$anchorName"
if _recursion_guard "$recursionExec"
then
[[ "$ub_import" != "true" ]] && _messagePlain_good 'reference: 'bash "$recursionExec" "$@" | _user_log_anchor
if [[ "$ub_import" != "true" ]]
then
bash "$recursionExec" "$@"
exit $?
fi
[[ "$ub_import" == "true" ]] && _messagePlain_good 'reference: 'bash "$recursionExec" "$ub_import_param" "$@" | _user_log_anchor
[[ "$ub_import" == "true" ]] && bash "$recursionExec" "$ub_import_param" "$@"
exit $?
fi
recursionExec="$HOME"/core/lab/"$anchorEntity""$anchorLabNameAlt"/_index/"$anchorName"
if _recursion_guard "$recursionExec"
then
[[ "$ub_import" != "true" ]] && _messagePlain_good 'reference: 'bash "$recursionExec" "$@" | _user_log_anchor
if [[ "$ub_import" != "true" ]]
then
bash "$recursionExec" "$@"
exit $?
fi
[[ "$ub_import" == "true" ]] && _messagePlain_good 'reference: 'bash "$recursionExec" "$ub_import_param" "$@" | _user_log_anchor
[[ "$ub_import" == "true" ]] && bash "$recursionExec" "$ub_import_param" "$@"
exit $?
fi
recursionExec="$HOME"/core/extra/lab/"$anchorEntity""$anchorLabNameAlt"/_index/"$anchorName"
if _recursion_guard "$recursionExec"
then
[[ "$ub_import" != "true" ]] && _messagePlain_good 'reference: 'bash "$recursionExec" "$@" | _user_log_anchor
if [[ "$ub_import" != "true" ]]
then
bash "$recursionExec" "$@"
exit $?
fi
[[ "$ub_import" == "true" ]] && _messagePlain_good 'reference: 'bash "$recursionExec" "$ub_import_param" "$@" | _user_log_anchor
[[ "$ub_import" == "true" ]] && bash "$recursionExec" "$ub_import_param" "$@"
exit $?
fi
_messagePlain_bad 'missing: '"$anchorSource" | _user_log_anchor
return 1
}
export anchorScriptAbsoluteLocation=$(_getScriptAbsoluteLocation)
export anchorScriptAbsoluteFolder=$(_getScriptAbsoluteFolder)
export anchorName=$(basename "$anchorScriptAbsoluteLocation" | sed 's/\.bat$//g')
export anchorSourceDir="iconArt"
export anchorSource="ubiquitous_bash.sh"
export anchorSourcePath="$anchorSourceDir"/"$anchorSource"
export anchorLabName=anchorLabName
export anchorLabNameAlt="$anchorLabName"Mini
export anchorEntity=""
#export anchorEntity="entity/"
if [[ "$anchorName" == "_anchor" ]]
then
! [[ -e "$anchorScriptAbsoluteFolder"/"$anchorSource" ]] && exit 1
"$anchorScriptAbsoluteFolder"/"$anchorSource" _anchor
exit "$?"
fi
if [[ "$1" == 'MSWselfReinterpret' ]]
then
# ATTENTION: DANGER: Not yet implemented. Add the alternate functionality in production use.
shift
exit 1
fi
# ATTENTION: DANGER: Comment out in production use.
#_test() {
# echo PASS-BASH
#}
#_test
# ATTENTION: DANGER: Uncomment in production use.
_launch_anchor "$@"
exit "$?"
#_findAnchorName .
#exit "$?"
exit 1
:b
REM Batch script is executable as both MSW batch file and UNIX BASH script.
REM This allows the anchor to self-execute as a more functional BASH script
REM if an appropriate Cygwin environment is installed at the expected location
REM C:\core\infrastructure\ubAnchorMSWselfReinterpret .
REM BASH functionality may not be implemented or adequately tested.
REM Structure is provided only to be used if continued MS de-facto monopoly degrades
REM hardware support for suitable UNIX platforms to the point of infeasibility.
REM https://stackoverflow.com/questions/29966924/cross-platform-command-line-script-e-g-bat-and-sh
REM rem(){ :;};rem '
REM @goto b
REM ';echo sh;exit
REM :b
REM @echo batch
REM @echo batch
REM ATTENTION: WARNING: Do NOT uncomment without correcting and testing all file paths used by the MSW/cygwin/UNIX environment!
REM DANGER: Beware this must behave correctly under BOTH MSW and native UNIX platforms.
REM IF EXIST "C:\core\infrastructure\ubAnchorMSWselfReinterpret\ubcp.cmd" (
REM "C:\core\infrastructure\ubAnchorMSWselfReinterpret\ubcp.cmd" "%~dp0%0" MSWselfReinterpret %*
REM goto end
REM REM exit
REM )
@echo off
REM Ubiquitous Bash Cygwin Portable - Anchor (Batch Version)
REM Retrieve value of such variables with: set BASH_FUNC__visualPrompt_promptCommand%%
REM set BASH_FUNC__visualPrompt_promptCommand%%=
set AUTOSSH_FIRST_POLL=
set AUTOSSH_GATETIME=
set AUTOSSH_POLL=
set BASH_FUNC__visualPrompt_promptCommand%%=
setx BASH_FUNC__visualPrompt_promptCommand%% "BASH_FUNC__visualPrompt_promptCommand%%" > nul 2>&1
set CHROME_CRASHPAD_PIPE_NAME=
set COLORTERM=
REM set COMMONPROGRAMFILES=
REM set COMPUTERNAME=
REM set COMSPEC=
REM set CWD=
set ChocolateyInstall=
set ChocolateyLastPathUpdate=
REM set CommonProgramFiles(x86)=
set CommonProgramW6432=
REM set DriverData=
set EMBEDDED=
set EXECIGNORE=
set GIT_ASKPASS=
set GROUP=
set HOSTNAME=
set HOST_GROUP_ID=
set HOST_USER_ID=
REM set LOCALAPPDATA=
set LOCALLISTENPORT=
set LOCALSSHPORT=
REM set LOGONSERVER=
REM set MSMPI_BENCHMARKS=
REM set MSMPI_BIN=
REM set MSWEXTPATH=
set MSWanchorName=
set MSWanchorSource=
set MSWanchorSourceDir=
set MSWanchorSourcePath=
REM set NUMBER_OF_PROCESSORS=
set OLDPWD=
set OLD_ANCHOR_PATH=
set ORIGINAL_XDG_CURRENT_DESKTOP=
REM set OS=
REM set OneDrive=
REM set OneDriveConsumer=
REM set PATH=C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files (x86)\VMware\VMware Workstation\bin\;C:\Program Files\Microsoft MPI\Bin\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\WinMerge;C:\ProgramData\chocolatey\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files\Git\cmd;C:\Users\mirage335\AppData\Local\Microsoft\WindowsApps;C:\Program Files (x86)\Nmap;C:\Users\mirage335\AppData\Local\Programs\Microsoft VS Code\bin
REM set PATH=
REM set "PATH=%MSWEXTPATH%"
IF NOT "%MSWEXTPATH%" == "" set "PATH=%MSWEXTPATH%"
REM set PATHEXT=
REM set PRINTER=
REM set PROCESSOR_ARCHITECTURE=
REM set PROCESSOR_IDENTIFIER=
REM set PROCESSOR_LEVEL=
REM set PROCESSOR_REVISION=
REM set PROFILEREAD=
REM set PROGRAMFILES=
REM set PROMPT=
set PROMPT_COMMAND=
REM set PS1=
set PSModulePath=
REM set PUBLIC=
set PYTHONHOME=
set PYTHONSTARTUP=
REM set ProgramFiles(x86)=
REM set ProgramW6432=
set SHLVL=
REM set SYSTEMDRIVE=
REM set SYSTEMROOT=
REM set TEMP=
set TERM=
set TERM_PROGRAM=
set TERM_PROGRAM_VERSION=
REM set TMP=
REM set TZ=
REM set USER=
REM set USERDOMAIN=
REM set USERDOMAIN_ROAMINGPROFILE=
REM set USERNAME=
REM set USERPROFILE=
set VBOX_MSI_INSTALL_PATH=
REM set VSCODE_GIT_ASKPASS_EXTRA_ARGS=
REM set VSCODE_GIT_ASKPASS_MAIN=
REM set VSCODE_GIT_ASKPASS_NODE=
REM set VSCODE_GIT_IPC_HANDLE=
REM set VSCODE_INJECTION=
REM set WINDIR=
set abstractfs_lock=
set abstractfs_root=
set actualFakeHome=
set arbitraryFakeHome=
set arg1=
set bootTmp=
set chrootDir=
set comment_shell_line=
set convertedMSWEXTPATH=
set currentDriveLetter_cygwin_uk4uPhB663kVcygT0q=
REM exit /b
REM goto :eof
set cygwinOverride_measureDateA=
set cygwinOverride_measureDateB=
set daemonPidFile=
set fakeHomeEditLib=
set flag__NOT_shell=
set gatewayName=
set globalArcDir=
set globalArcFS=
set globalArcTmp=
set globalBuildDir=
set globalBuildFS=
set globalBuildTmp=
set globalFakeHome=
set globalVirtDir=
set globalVirtFS=
set globalVirtTmp=
set hostMemoryQuantity=
set hostMemoryTotal=
set hostToGuestDir=
set hostToGuestFiles=
set hostToGuestISO=
set importLog=
set initPWD=
set instancedDownloadsDir=
set instancedFakeHome=
set instancedProjectDir=
set instancedVirtDir=
set instancedVirtFS=
set instancedVirtHome=
set instancedVirtTmp=
set keepFakeHome=
set keepKeys_SSH=
set lock_closed=
set lock_closing=
set lock_emergency=
set lock_instance=
set lock_instancing=
set lock_loop_image=
set lock_open=
set lock_open_chroot=
set lock_open_docker=
set lock_open_image=
set lock_open_qemu=
set lock_open_vbox=
set lock_opening=
set lock_pathlock=
set lock_quicktmp=
set logTmp=
set lowsessionid=
set markup_terminal_cmd_begin=
set markup_terminal_cmd_end=
set matchingEMBEDDED=
set netName=
set netTimeout=
set objectDir=
set objectName=
set outerPWD=
set override_cygwin_vncviewer=
set permaLog=
set pidFile=
set profileScriptFolder=
set profileScriptLocation=
set queryTmp=
set safeTmp=
set safeTmpSSH=
set scopeTmp=
set scriptAbsoluteFolder=
set scriptAbsoluteLocation=
set scriptBin=
set scriptBundle=
set scriptLib=
set scriptLocal=
set scriptTokens=
set sessionid=
set sharedGuestProjectDir=
set sharedGuestProjectDirDefault=
set shortFakeHome=
set shortTmp=
set tmpSelf=
set uPID=
set ubVirtImageLocal=
set ub_setScriptChecksum_contents=
set ub_setScriptChecksum_contents_cygwinOverride=
set ub_setScriptChecksum_header=
set ubcp_cmd_dir=
set ubcp_cmd_file=
set ubcp_cmd_path=
set ubiquitiousBashID=
set ubiquitiousBashIDnano=
set ubiquitiousBashIDshort=
set ubiquitousBashID=
set ubiquitousBashIDnano=
set ubiquitousBashIDshort=
set vboxRaw=
set virtGuestHome=
set virtGuestHomeDrop=
set virtGuestUser=
set virtGuestUserDrop=
set vmMemoryAllocationDefault=
set vncPasswdFile=
if "%~1"=="ubAnchorSelfTestOnly" (
echo PASS-BATCH
goto end
REM exit
)
REM CAUTION: BROKEN! Attemtps to reset Cygwin 'environment variables' to prevent incorrect rewriting of '$PATH' variable. Apparently inadequate.
if NOT "%OLD_ANCHOR_PATH%" == "" (
set "PATH=%OLD_ANCHOR_PATH%"
set "OLD_ANCHOR_PATH="
)
if "%OLD_ANCHOR_PATH%" == "" (
set "OLD_ANCHOR_PATH=%PATH%"
)
set "CYGWIN_PATH="
set "ORIGINAL_PATH="
set "CYGWIN_DRIVE="
set "cygwin_CWD_onceOnly_done="
set "CYGWIN="
set "ProgramData="
set "CYGWIN_ROOT="
set "HOMEPATH="
set "CYGWIN_USEWINPATH="
set "HOME="
set "HOMEDRIVE="
set "HOMEPATH="
set "INFOPATH="
set "LANG="
set "PWD="
set "SHELL="