@ -25,7 +25,7 @@ set -- "$@" "a=[Hide <#;Hide set;S 1 list]"; set -- : "$@";$1 = @'
@ REM in batch scripts - array syntax with square brackets is a simulation of arrays or associative arrays.
@ REM in batch scripts - array syntax with square brackets is a simulation of arrays or associative arrays.
@ REM note that many shells linked as sh do not support substition syntax and may fail - e.g dash etc - generally bash should be used in this context
@ REM note that many shells linked as sh do not support substition syntax and may fail - e.g dash etc - generally bash should be used in this context
@ SETLOCAL EnableExtensions EnableDelayedExpansion
@ SETLOCAL EnableExtensions EnableDelayedExpansion
@ SET " validshelltypes= powershell______ sh______________ wslbash_________ bash____________ tcl_____________ perl____________ none____________ "
@ SET " validshelltypes= pwsh____________ p owershell______ sh______________ wslbash_________ bash____________ tcl_____________ perl____________ none____________ "
@ REM for batch - only win32 is relevant - but other scripts on other platforms also parse the nextshell block to determine next shell to launch
@ REM for batch - only win32 is relevant - but other scripts on other platforms also parse the nextshell block to determine next shell to launch
@ REM nextshellpath and nextshelltype indices (underscore-padded to 16wide) are "other" plus those returned by Tcl platform pkg e.g win32,linux,freebsd,macosx
@ REM nextshellpath and nextshelltype indices (underscore-padded to 16wide) are "other" plus those returned by Tcl platform pkg e.g win32,linux,freebsd,macosx
@ REM The horrible underscore-padded fixed-widths are to keep the batch labels aligned whilst allowing values to be set
@ REM The horrible underscore-padded fixed-widths are to keep the batch labels aligned whilst allowing values to be set
@ -176,12 +176,12 @@ set -- "$@" "a=[Hide <#;Hide set;S 1 list]"; set -- : "$@";$1 = @'
)
)
@ REM avoid using CALL to launch pwsh,tclsh etc - it will intercept some args such as /?
@ REM avoid using CALL to launch pwsh,tclsh etc - it will intercept some args such as /?
@ IF " !selected_shelltype_trimmed! " == " none " (
@ IF " !selected_shelltype_trimmed! " == " none " (
SET selected_shelltype_trimmed = po wer shell
SET selected_shelltype_trimmed = pwsh
)
)
@ IF " !selected_shelltype_trimmed! " == " po wer shell " (
@ IF " !selected_shelltype_trimmed! " == " pwsh " (
REM pwsh vs powershell hasn't been tested because we didn't need to copy cmd to ps1 this time
REM pwsh vs powershell hasn't been tested because we didn't need to copy cmd to ps1 this time
REM test availability of preferred option of powershell7+ pwsh
REM test availability of preferred option of powershell7+ pwsh
pwsh -nop -nol -c set-executionpolicy -Scope Process Unrestricted; write-host " statusmessage: pwsh-found " > NUL
pwsh -nop -nol -c set-executionpolicy -Scope Process Unrestricted 2 > NUL ; write-host " statusmessage: pwsh-found " > NUL
SET pwshtest_exitcode = !errorlevel!
SET pwshtest_exitcode = !errorlevel!
REM ECHO pwshtest_exitcode !pwshtest_exitcode!
REM ECHO pwshtest_exitcode !pwshtest_exitcode!
REM fallback to powershell if pwsh failed
REM fallback to powershell if pwsh failed
@ -189,11 +189,15 @@ set -- "$@" "a=[Hide <#;Hide set;S 1 list]"; set -- : "$@";$1 = @'
pwsh -nop -nol -c set-executionpolicy -Scope Process Unrestricted; " %~dp0 %~n0 .ps1 " %arglist%
pwsh -nop -nol -c set-executionpolicy -Scope Process Unrestricted; " %~dp0 %~n0 .ps1 " %arglist%
SET task_exitcode = !errorlevel!
SET task_exitcode = !errorlevel!
) ELSE (
) ELSE (
REM CALL powershell -nop -nol -c write-host powershell-found
REM TODO prompt user with option to call script to install pwsh using winget
REM powershell -nop -nol -file "%~dp0%~n0.ps1" %*
REM powershell -nop -nol -c set-executionpolicy -Scope Process Unrestricted; "%~dp0%~n0.ps1" %arglist%
powershell -nop -nol -c set-executionpolicy -Scope Process Unrestricted; %~dp0 %~n0 .ps1" %arglist%
powershell -nop -nol -ExecutionPolicy Bypass -c " %~dp0 %~n0 .ps1" %arglist%
SET task_exitcode = !errorlevel!
SET task_exitcode = !errorlevel!
)
)
) ELSE (
IF " !selected_shelltype_trimmed! " == " powershell " (
powershell -nop -nol -ExecutionPolicy Bypass -c " %~dp0 %~n0 .ps1 " %arglist%
SET task_exitcode = !errorlevel!
) ELSE (
) ELSE (
IF " !selected_shelltype_trimmed! " == " wslbash " (
IF " !selected_shelltype_trimmed! " == " wslbash " (
CALL : getWslPath %winpath% wslpath
CALL : getWslPath %winpath% wslpath
@ -212,13 +216,11 @@ set -- "$@" "a=[Hide <#;Hide set;S 1 list]"; set -- : "$@";$1 = @'
ECHO %fname% has invalid nextshelltype value %selected_shelltype% valid options are %validshelltypes%
ECHO %fname% has invalid nextshelltype value %selected_shelltype% valid options are %validshelltypes%
SET task_exitcode = 66
SET task_exitcode = 66
@ REM boundary padding
@ REM boundary padding
@ REM boundary padding
@ REM boundary padding
@ REM boundary padding
GOTO : exit_multishell
GOTO : exit_multishell
)
)
)
)
)
)
)
@ REM batch file library functions
@ REM batch file library functions
@ REM boundary padding
@ REM boundary padding
@ GOTO : endlib
@ GOTO : endlib
@ -479,6 +481,9 @@ namespace eval ::punk::multishell {
# -- --- --- --- --- --- --- --- --- --- --- ---
# -- --- --- --- --- --- --- --- --- --- --- ---
#< tcl-payload>
#< tcl-payload>
set url_kitbase " https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master "
package require http
package require http
package require tls
package require tls
http::register https 443 [list ::tls::socket -autoservername true]
http::register https 443 [list ::tls::socket -autoservername true]
@ -489,15 +494,32 @@ set runtime_available 0
set scriptdir [file dirname [info script]]
set scriptdir [file dirname [info script]]
switch -- $os {
switch -- $os {
" win32 " {
" win32 " {
set url " https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win64/tclsh901t .exe"
set url " $url_kitbase/win32-x86_64/tclsh902z .exe"
set output [file join $scriptdir " ../src/runtime/tclsh901t .exe " ]
set output [file join $scriptdir " ../src/runtime/tclsh902z .exe " ]
set runtime_available 1
set runtime_available 1
}
}
" linux " {
" linux " {
puts stderr " No runtime currently available for linux "
switch -glob -- $plat {
*x86_64 {
set url " $url_kitbase/linux-x86_64/tclkit-902-Linux64-intel-dyn "
set output [file join $scriptdir " ../src/runtime/tclkit-902-Linux64-intel-dyn " ]
set runtime_available 1
}
*arm {
set url " $url_kitbase/linux-x86_64/tclkit-902-Linux64-arm-dyn "
set output [file join $scriptdir " ../src/runtime/tclkit-902-Linux64-arm-dyn " ]
set runtime_available 1
}
default {
#
puts stderr " No runtime currently available for linux $::tcl_platform(machine) "
}
}
}
}
" macosx " {
" macosx " {
puts stderr " No runtime currently available for linux "
set url " $url_kitbase/macosx/tclkit-902-Darwin64-dyn "
set output [file join $scriptdir " ../src/runtime/tclkit-902-Darwin64-dyn " ]
set runtime_available 1
}
}
" freebsd " {
" freebsd " {
puts stderr " No runtime currently available for freebsd "
puts stderr " No runtime currently available for freebsd "
@ -652,11 +674,30 @@ fi
#< shell-payload>
#< shell-payload>
$url_kitbase=" https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master "
runtime_available=0
runtime_available=0
if [[ " $ O S T Y P E " == " linux " * ]]; then
if [[ " $ O S T Y P E " == " linux " * ]]; then
arch=$(uname -i)
if [[ " $ a r c h " == " x86_64 " * ]]; then
url=" ${url_kitbase}/linux-x86_64/tclkit-902-Linux64-intel-dyn "
output=" ../src/runtime/tclkit-902-Linux64-intel-dyn "
$runtime_available=1
elif [[ " $arch " == " arm " * ]]; then
url=" ${url_kitbase}/linux-x86_64/tclkit-902-Linux64-arm-dyn "
output=" ../src/runtime/tclkit-902-Linux64-arm-dyn "
$runtime_available=1
fi
if [[ " $ r u n t i m e _ a v a i l a b l e " - e q 1 ] ] ; t h e n
echo " Please ensure libxFt.so.2 is available "
echo " e.g on Ubuntu: sudo apt-get install libxft2 "
fi
os=" linux "
os=" linux "
elif [[ " $OSTYPE " == " darwin " * ]]; then
elif [[ " $OSTYPE " == " darwin " * ]]; then
os=" macosx "
os=" macosx "
#assumed to be Mach-O 'universal binaries' for both x86-64 and arm? - REVIEW
url=" ${url_kitbase}/macosx/tclkit-902-Darwin64-dyn "
output=" ../src/runtime/tclkit-902-Darwin64-dyn "
$runtime_available=1
elif [[ " $OSTYPE " == " freebsd " * ]]; then
elif [[ " $OSTYPE " == " freebsd " * ]]; then
os=" freebsd "
os=" freebsd "
elif [[ " $OSTYPE " == " dragonflybsd " * ]]; then
elif [[ " $OSTYPE " == " dragonflybsd " * ]]; then
@ -665,14 +706,13 @@ elif [[ "$OSTYPE" == "netbsd"* ]]; then
os=" netbsd "
os=" netbsd "
elif [[ " $OSTYPE " == " win32 " ]]; then
elif [[ " $OSTYPE " == " win32 " ]]; then
os=" win32 "
os=" win32 "
url=" ${url_kitbase}/win32-x86_64/tclsh902z.exe "
runtime_available=1
runtime_available=1
url=" https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win64/tclsh901t.exe "
#scriptdir?
#scriptdir?
output=" ../src/runtime/tclsh901t .exe "
output=" ../src/runtime/tclsh902z .exe "
elif [[ " $OSTYPE " == " msys " ]]; then
elif [[ " $OSTYPE " == " msys " ]]; then
echo MSYS
echo MSYS
os=" win32 "
os=" win32 "
runtime_available = 1
#use 'command -v' (shell builtin preferred over external which)
#use 'command -v' (shell builtin preferred over external which)
interp = `ps -p $$ | awk '$1 != " PID " {print $(NF)}' | tr -d '()' | sed -E 's/^. *\/| ^- //'`
interp = `ps -p $$ | awk '$1 != " PID " {print $(NF)}' | tr -d '()' | sed -E 's/^. *\/| ^- //'`
shellpath=`command -v $interp`
shellpath=`command -v $interp`
@ -680,9 +720,10 @@ elif [[ "$OSTYPE" == "msys" ]]; then
#" c:/windows/system32/ " is quite likely in the path ahead of msys,git etc.
#" c:/windows/system32/ " is quite likely in the path ahead of msys,git etc.
#This breaks calls to various unix utils such as sed etc (wsl related?)
#This breaks calls to various unix utils such as sed etc (wsl related?)
export PATH=" $shellfolder${PATH:+:${PATH}} "
export PATH=" $shellfolder${PATH:+:${PATH}} "
url=" https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win64/tclsh901t .exe"
url=" ${url_kitbase}/win32-x86_64/tclsh902z .exe"
#scriptdir?
#scriptdir?
output=" ../src/runtime/tclsh901t.exe "
output=" ../src/runtime/tclsh902z.exe "
runtime_available=1
else
else
#os=" $OSTYPE "
#os=" $OSTYPE "
os=" other "
os=" other "
@ -908,8 +949,8 @@ if ($matches.count) {
#< powershell-payload>
#< powershell-payload>
$url = " https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win64/tclsh901t .exe "
$url = " https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win32-x86_64/tclsh902z .exe "
$output = " $(join-path $PSScriptRoot " ..\src\runtime\tclsh901t .exe" ) "
$output = " $(join-path $PSScriptRoot " ..\src\runtime\tclsh902z .exe" ) "
if (-not(Test-Path - P a t h $ o u t p u t - P a t h T y p e L e a f ) ) {
if (-not(Test-Path - P a t h $ o u t p u t - P a t h T y p e L e a f ) ) {
Write-Host " Downloading from $url ... "
Write-Host " Downloading from $url ... "