@ -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 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
@ 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 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
@ -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 /?
@ 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 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!
REM ECHO pwshtest_exitcode !pwshtest_exitcode!
REM fallback to powershell if pwsh failed
@ -189,33 +189,35 @@ set -- "$@" "a=[Hide <#;Hide set;S 1 list]"; set -- : "$@";$1 = @'
pwsh -nop -nol -c set-executionpolicy -Scope Process Unrestricted; " %~dp0 %~n0 .ps1 " %arglist%
SET task_exitcode = !errorlevel!
) ELSE (
REM CALL powershell -nop -nol -c write-host powershell-found
REM powershell -nop -nol -file "%~dp0%~n0.ps1" %*
powershell -nop -nol -c set-executionpolicy -Scope Process Unrestricted; %~dp0 %~n0 .ps1" %arglist%
REM TODO prompt user with option to call script to install pwsh using winget
REM 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!
)
) ELSE (
IF " !selected_shelltype_trimmed! " == " wslbash " (
CALL : getWslPath %winpath% wslpath
REM ECHO wslfullpath "!wslpath!%fname%"
%selected_shellpath_trimmed% " !wslpath! %fname% " %arglist%
IF " !selected_shelltype_trimmed! " == " powershell " (
powershell -nop -nol -ExecutionPolicy Bypass -c " %~dp0 %~n0 .ps1 " %arglist%
SET task_exitcode = !errorlevel!
) ELSE (
REM perl or tcl or sh or bash
IF NOT " x %keyRemoved% " == " x %validshelltypes% " (
REM sh on windows uses /c/ instead of /mnt/c - at least if using msys. Todo, review what is the norm on windows with and without msys2,cygwin,wsl
REM and what logic if any may be needed. For now sh with /c/xxx seems to work the same as sh with c:/xxx
REM The compound statement with trailing call is required to stop batch termination confirmation, whilst still capturing exitcode
@ ECHO HERE " !selected_shelltype_trimmed! " " !selected_shellpath_trimmed! "
%selected_shellpath_trimmed% " %~dp0 %fname% " %arglist% & SET task_exitcode = !errorlevel! & Call ;
IF " !selected_shelltype_trimmed! " == " wslbash " (
CALL : getWslPath %winpath% wslpath
REM ECHO wslfullpath "!wslpath!%fname%"
%selected_shellpath_trimmed% " !wslpath! %fname% " %arglist%
SET task_exitcode = !errorlevel!
) ELSE (
ECHO %fname% has invalid nextshelltype value %selected_shelltype% valid options are %validshelltypes%
SET task_exitcode = 66
@ REM boundary padding
@ REM boundary padding
@ REM boundary padding
@ REM boundary padding
GOTO : exit_multishell
REM perl or tcl or sh or bash
IF NOT " x %keyRemoved% " == " x %validshelltypes% " (
REM sh on windows uses /c/ instead of /mnt/c - at least if using msys. Todo, review what is the norm on windows with and without msys2,cygwin,wsl
REM and what logic if any may be needed. For now sh with /c/xxx seems to work the same as sh with c:/xxx
REM The compound statement with trailing call is required to stop batch termination confirmation, whilst still capturing exitcode
@ ECHO HERE " !selected_shelltype_trimmed! " " !selected_shellpath_trimmed! "
%selected_shellpath_trimmed% " %~dp0 %fname% " %arglist% & SET task_exitcode = !errorlevel! & Call ;
) ELSE (
ECHO %fname% has invalid nextshelltype value %selected_shelltype% valid options are %validshelltypes%
SET task_exitcode = 66
@ REM boundary padding
GOTO : exit_multishell
)
)
)
)
@ -479,6 +481,9 @@ namespace eval ::punk::multishell {
# -- --- --- --- --- --- --- --- --- --- --- ---
#< tcl-payload>
set url_kitbase " https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master "
package require http
package require tls
http::register https 443 [list ::tls::socket -autoservername true]
@ -489,15 +494,32 @@ set runtime_available 0
set scriptdir [file dirname [info script]]
switch -- $os {
" win32 " {
set url " https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win64/tclsh901t .exe"
set output [file join $scriptdir " ../src/runtime/tclsh901t .exe " ]
set url " $url_kitbase/win32-x86_64/tclsh902z .exe"
set output [file join $scriptdir " ../src/runtime/tclsh902z .exe " ]
set runtime_available 1
}
" 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 " {
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 " {
puts stderr " No runtime currently available for freebsd "
@ -652,11 +674,30 @@ fi
#< shell-payload>
runtime_available = 0
$url_kitbase=" https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master "
runtime_available=0
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 "
elif [[ " $OSTYPE " == " darwin " * ]]; then
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
os=" freebsd "
elif [[ " $OSTYPE " == " dragonflybsd " * ]]; then
@ -665,14 +706,13 @@ elif [[ "$OSTYPE" == "netbsd"* ]]; then
os=" netbsd "
elif [[ " $OSTYPE " == " win32 " ]]; then
os=" win32 "
runtime_available = 1
url=" https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win64/tclsh901t.exe "
url=" ${url_kitbase}/win32-x86_64/tclsh902z.exe "
runtime_available=1
#scriptdir?
output=" ../src/runtime/tclsh901t .exe "
output=" ../src/runtime/tclsh902z .exe "
elif [[ " $OSTYPE " == " msys " ]]; then
echo MSYS
os=" win32 "
runtime_available = 1
#use 'command -v' (shell builtin preferred over external which)
interp = `ps -p $$ | awk '$1 != " PID " {print $(NF)}' | tr -d '()' | sed -E 's/^. *\/| ^- //'`
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.
#This breaks calls to various unix utils such as sed etc (wsl related?)
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?
output=" ../src/runtime/tclsh901t.exe "
output=" ../src/runtime/tclsh902z.exe "
runtime_available=1
else
#os=" $OSTYPE "
os=" other "
@ -908,8 +949,8 @@ if ($matches.count) {
#< powershell-payload>
$url = " https://www.gitea1.intx.com.au/jn/punkbin/raw/branch/master/win64/tclsh901t .exe "
$output = " $(join-path $PSScriptRoot " ..\src\runtime\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\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 ) ) {
Write-Host " Downloading from $url ... "