Skip to content

Commit 42a3436

Browse files
committed
Upstream.
1 parent e8d28c2 commit 42a3436

File tree

4 files changed

+136
-23
lines changed

4 files changed

+136
-23
lines changed

compile.sh

Lines changed: 65 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _ub_cksum_special_derivativeScripts_contents() {
3636
#export ub_setScriptChecksum_disable='true'
3737
( [[ -e "$0".nck ]] || [[ "${BASH_SOURCE[0]}" != "${0}" ]] || [[ "$1" == '--profile' ]] || [[ "$1" == '--script' ]] || [[ "$1" == '--call' ]] || [[ "$1" == '--return' ]] || [[ "$1" == '--devenv' ]] || [[ "$1" == '--shell' ]] || [[ "$1" == '--bypass' ]] || [[ "$1" == '--parent' ]] || [[ "$1" == '--embed' ]] || [[ "$1" == '--compressed' ]] || [[ "$0" == "/bin/bash" ]] || [[ "$0" == "-bash" ]] || [[ "$0" == "/usr/bin/bash" ]] || [[ "$0" == "bash" ]] ) && export ub_setScriptChecksum_disable='true'
3838
export ub_setScriptChecksum_header='2591634041'
39-
export ub_setScriptChecksum_contents='3463106160'
39+
export ub_setScriptChecksum_contents='3412969308'
4040

4141
# CAUTION: Symlinks may cause problems. Disable this test for such cases if necessary.
4242
# WARNING: Performance may be crucial here.
@@ -823,7 +823,16 @@ then
823823
#alias l='_wsl'
824824
alias u='_wsl'
825825
fi
826-
826+
827+
_sudo_cygwin-if_parameter-skip2() {
828+
[[ "$1" == "-u" ]] && return 0
829+
return 1
830+
}
831+
_sudo_cygwin-if_parameter-skip1() {
832+
[[ "$1" == "-n" ]] && return 0
833+
[[ "$1" == "--preserve-env"* ]] && return 0
834+
return 1
835+
}
827836

828837
# CAUTION: Fragile, at best.
829838
# DANGER: MSW apparently does not necessarily allow 'Administrator' access to all network 'drives'. Workaround copying of obvious files is limited.
@@ -844,12 +853,46 @@ _sudo_cygwin_sequence() {
844853
# 'cygstart/runas doesn't handle arguments with spaces correctly so create'
845854
# 'a script that will do so properly.'
846855
echo "#!/bin/bash" >> "$safeTmp"/cygwin_sudo_temp.sh
856+
857+
echo "cd \"$PWD"\" >> "$safeTmp"/cygwin_sudo_temp.sh
858+
847859
echo "export PATH=\"$PATH\"" >> "$safeTmp"/cygwin_sudo_temp.sh
848-
849-
860+
861+
# No production use.
862+
echo "export GH_TOKEN=\"$GH_TOKEN\"" >> "$safeTmp"/cygwin_sudo_temp.sh
863+
echo "export INPUT_GITHUB_TOKEN=\"$INPUT_GITHUB_TOKEN\"" >> "$safeTmp"/cygwin_sudo_temp.sh
864+
echo "export TOKEN=\"$TOKEN\"" >> "$safeTmp"/cygwin_sudo_temp.sh
865+
866+
# No production use.
867+
echo "export nonet=\"$nonet\"" >> "$safeTmp"/cygwin_sudo_temp.sh
868+
echo "export devfast=\"$devfast\"" >> "$safeTmp"/cygwin_sudo_temp.sh
869+
echo "export skimfast=\"$skimfast\"" >> "$safeTmp"/cygwin_sudo_temp.sh
870+
871+
local currentParam1
872+
while _sudo_cygwin-if_parameter-skip2 "$@" || _sudo_cygwin-if_parameter-skip1 "$@"
873+
do
874+
currentParam1="$1"
875+
876+
if _sudo_cygwin-if_parameter-skip2 "$currentParam1"
877+
then
878+
! shift && _messageFAIL
879+
! shift && _messageFAIL
880+
currentParam1=""
881+
fi
882+
883+
if _sudo_cygwin-if_parameter-skip1 "$currentParam1"
884+
then
885+
! shift && _messageFAIL
886+
currentParam1=""
887+
fi
888+
done
889+
890+
#echo 'local currentExitStatus' >> "$safeTmp"/cygwin_sudo_temp.sh
850891
_safeEcho_newline "$safeTmp"/_bin.bat "$@" >> "$safeTmp"/cygwin_sudo_temp.sh
892+
echo 'currentExitStatus=$?' >> "$safeTmp"/cygwin_sudo_temp.sh
851893
echo 'echo > "'"$safeTmp"'"/sequenceDone_'"$ubiquitousBashID" >> "$safeTmp"/cygwin_sudo_temp.sh
852894
echo 'sleep 3' >> "$safeTmp"/cygwin_sudo_temp.sh
895+
echo 'exit $currentExitStatus' >> "$safeTmp"/cygwin_sudo_temp.sh
853896
chmod u+x "$safeTmp"/cygwin_sudo_temp.sh
854897

855898

@@ -860,6 +903,7 @@ _sudo_cygwin_sequence() {
860903
chmod u+x "$safeTmp"/"$currentScriptBasename"
861904

862905
cp "$scriptLib"/ubiquitous_bash/_bin.bat "$safeTmp"/_bin.bat 2>/dev/null
906+
#cp /home/root/.ubcore/ubiquitous_bash/_bin.bat "$safeTmp"/_bin.bat 2>/dev/null
863907
cp -f "$scriptAbsoluteFolder"/_bin.bat "$safeTmp"/_bin.bat 2>/dev/null
864908
chmod u+x "$safeTmp"/_bin.bat
865909

@@ -905,22 +949,22 @@ _sudo_cygwin() {
905949
if _if_cygwin && type cygstart > /dev/null 2>&1
906950
then
907951
sudo_cygwin() {
908-
[[ "$1" == "-n" ]] && shift
952+
#[[ "$1" == "-n" ]] && shift
909953
if type cygstart > /dev/null 2>&1
910954
then
911955
_sudo_cygwin "$@"
912956
#cygstart --action=runas "$@"
913957
#"$@"
914958
return
915-
else
916-
"$@"
917-
return
918959
fi
919960

961+
"$@"
962+
return
963+
920964
return 1
921965
}
922966
sudoc() {
923-
[[ "$1" == "-n" ]] && return 1
967+
#[[ "$1" == "-n" ]] && return 1
924968
sudo_cygwin "$@"
925969
}
926970
alias sudo=sudoc
@@ -8792,7 +8836,18 @@ _python() {
87928836
_sudo() {
87938837
_safe_declare_uid
87948838

8795-
sudo -n "$scriptAbsoluteLocation" _bin "$@"
8839+
if ! _if_cygwin
8840+
then
8841+
sudo -n "$scriptAbsoluteLocation" _bin "$@"
8842+
return
8843+
fi
8844+
if _if_cygwin
8845+
then
8846+
_sudo_cygwin "$@"
8847+
return
8848+
fi
8849+
8850+
return 1
87968851
}
87978852

87988853
_true() {

ubiquitous_bash.sh

Lines changed: 69 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ _ub_cksum_special_derivativeScripts_contents() {
3636
#export ub_setScriptChecksum_disable='true'
3737
( [[ -e "$0".nck ]] || [[ "${BASH_SOURCE[0]}" != "${0}" ]] || [[ "$1" == '--profile' ]] || [[ "$1" == '--script' ]] || [[ "$1" == '--call' ]] || [[ "$1" == '--return' ]] || [[ "$1" == '--devenv' ]] || [[ "$1" == '--shell' ]] || [[ "$1" == '--bypass' ]] || [[ "$1" == '--parent' ]] || [[ "$1" == '--embed' ]] || [[ "$1" == '--compressed' ]] || [[ "$0" == "/bin/bash" ]] || [[ "$0" == "-bash" ]] || [[ "$0" == "/usr/bin/bash" ]] || [[ "$0" == "bash" ]] ) && export ub_setScriptChecksum_disable='true'
3838
export ub_setScriptChecksum_header='2591634041'
39-
export ub_setScriptChecksum_contents='2846327392'
39+
export ub_setScriptChecksum_contents='119795638'
4040

4141
# CAUTION: Symlinks may cause problems. Disable this test for such cases if necessary.
4242
# WARNING: Performance may be crucial here.
@@ -823,7 +823,16 @@ then
823823
#alias l='_wsl'
824824
alias u='_wsl'
825825
fi
826-
826+
827+
_sudo_cygwin-if_parameter-skip2() {
828+
[[ "$1" == "-u" ]] && return 0
829+
return 1
830+
}
831+
_sudo_cygwin-if_parameter-skip1() {
832+
[[ "$1" == "-n" ]] && return 0
833+
[[ "$1" == "--preserve-env"* ]] && return 0
834+
return 1
835+
}
827836

828837
# CAUTION: Fragile, at best.
829838
# DANGER: MSW apparently does not necessarily allow 'Administrator' access to all network 'drives'. Workaround copying of obvious files is limited.
@@ -844,12 +853,46 @@ _sudo_cygwin_sequence() {
844853
# 'cygstart/runas doesn't handle arguments with spaces correctly so create'
845854
# 'a script that will do so properly.'
846855
echo "#!/bin/bash" >> "$safeTmp"/cygwin_sudo_temp.sh
856+
857+
echo "cd \"$PWD"\" >> "$safeTmp"/cygwin_sudo_temp.sh
858+
847859
echo "export PATH=\"$PATH\"" >> "$safeTmp"/cygwin_sudo_temp.sh
848-
849-
860+
861+
# No production use.
862+
echo "export GH_TOKEN=\"$GH_TOKEN\"" >> "$safeTmp"/cygwin_sudo_temp.sh
863+
echo "export INPUT_GITHUB_TOKEN=\"$INPUT_GITHUB_TOKEN\"" >> "$safeTmp"/cygwin_sudo_temp.sh
864+
echo "export TOKEN=\"$TOKEN\"" >> "$safeTmp"/cygwin_sudo_temp.sh
865+
866+
# No production use.
867+
echo "export nonet=\"$nonet\"" >> "$safeTmp"/cygwin_sudo_temp.sh
868+
echo "export devfast=\"$devfast\"" >> "$safeTmp"/cygwin_sudo_temp.sh
869+
echo "export skimfast=\"$skimfast\"" >> "$safeTmp"/cygwin_sudo_temp.sh
870+
871+
local currentParam1
872+
while _sudo_cygwin-if_parameter-skip2 "$@" || _sudo_cygwin-if_parameter-skip1 "$@"
873+
do
874+
currentParam1="$1"
875+
876+
if _sudo_cygwin-if_parameter-skip2 "$currentParam1"
877+
then
878+
! shift && _messageFAIL
879+
! shift && _messageFAIL
880+
currentParam1=""
881+
fi
882+
883+
if _sudo_cygwin-if_parameter-skip1 "$currentParam1"
884+
then
885+
! shift && _messageFAIL
886+
currentParam1=""
887+
fi
888+
done
889+
890+
#echo 'local currentExitStatus' >> "$safeTmp"/cygwin_sudo_temp.sh
850891
_safeEcho_newline "$safeTmp"/_bin.bat "$@" >> "$safeTmp"/cygwin_sudo_temp.sh
892+
echo 'currentExitStatus=$?' >> "$safeTmp"/cygwin_sudo_temp.sh
851893
echo 'echo > "'"$safeTmp"'"/sequenceDone_'"$ubiquitousBashID" >> "$safeTmp"/cygwin_sudo_temp.sh
852894
echo 'sleep 3' >> "$safeTmp"/cygwin_sudo_temp.sh
895+
echo 'exit $currentExitStatus' >> "$safeTmp"/cygwin_sudo_temp.sh
853896
chmod u+x "$safeTmp"/cygwin_sudo_temp.sh
854897

855898

@@ -860,6 +903,7 @@ _sudo_cygwin_sequence() {
860903
chmod u+x "$safeTmp"/"$currentScriptBasename"
861904

862905
cp "$scriptLib"/ubiquitous_bash/_bin.bat "$safeTmp"/_bin.bat 2>/dev/null
906+
#cp /home/root/.ubcore/ubiquitous_bash/_bin.bat "$safeTmp"/_bin.bat 2>/dev/null
863907
cp -f "$scriptAbsoluteFolder"/_bin.bat "$safeTmp"/_bin.bat 2>/dev/null
864908
chmod u+x "$safeTmp"/_bin.bat
865909

@@ -905,22 +949,22 @@ _sudo_cygwin() {
905949
if _if_cygwin && type cygstart > /dev/null 2>&1
906950
then
907951
sudo_cygwin() {
908-
[[ "$1" == "-n" ]] && shift
952+
#[[ "$1" == "-n" ]] && shift
909953
if type cygstart > /dev/null 2>&1
910954
then
911955
_sudo_cygwin "$@"
912956
#cygstart --action=runas "$@"
913957
#"$@"
914958
return
915-
else
916-
"$@"
917-
return
918959
fi
919960

961+
"$@"
962+
return
963+
920964
return 1
921965
}
922966
sudoc() {
923-
[[ "$1" == "-n" ]] && return 1
967+
#[[ "$1" == "-n" ]] && return 1
924968
sudo_cygwin "$@"
925969
}
926970
alias sudo=sudoc
@@ -24432,7 +24476,10 @@ PARAMETER num_ctx 6144' > Llama-augment.Modelfile
2443224476

2443324477
! ollama create Llama-augment -f Llama-augment.Modelfile && _messagePlain_bad 'bad: FAIL: ollama create Llama-augment' && _messageFAIL
2443424478

24435-
! echo | sudo -n tee /AI-Llama-augment > /dev/null && _messagePlain_bad 'bad: FAIL: echo | sudo -n tee /AI-Llama-augment' && _messageFAIL
24479+
if ! _if_cygwin
24480+
then
24481+
! echo | sudo -n tee /AI-Llama-augment > /dev/null && _messagePlain_bad 'bad: FAIL: echo | sudo -n tee /AI-Llama-augment' && _messageFAIL
24482+
fi
2443624483

2443724484
rm -f llama-3.1-8b-instruct-abliterated.Q4_K_M.gguf
2443824485
rm -f Llama-augment.Modelfile
@@ -60066,7 +60113,18 @@ _python() {
6006660113
_sudo() {
6006760114
_safe_declare_uid
6006860115

60069-
sudo -n "$scriptAbsoluteLocation" _bin "$@"
60116+
if ! _if_cygwin
60117+
then
60118+
sudo -n "$scriptAbsoluteLocation" _bin "$@"
60119+
return
60120+
fi
60121+
if _if_cygwin
60122+
then
60123+
_sudo_cygwin "$@"
60124+
return
60125+
fi
60126+
60127+
return 1
6007060128
}
6007160129

6007260130
_true() {

0 commit comments

Comments
 (0)