From 2f57ff757bb71e5e445b288d68deaab3ade90a9d Mon Sep 17 00:00:00 2001 From: Julian Noble Date: Mon, 23 Feb 2026 01:48:11 +1100 Subject: [PATCH] short-term fix for bin/runtime.cmd listing and runtime selectin, fix logic errors in last --- bin/runtime.cmd | 32 ++++++++++++------- src/make.tcl | 4 +-- .../custom/_project/punk.basic/src/make.tcl | 4 +-- .../_project/punk.project-0.1/src/make.tcl | 4 +-- .../_project/punk.shell-0.1/src/make.tcl | 4 +-- src/scriptapps/runtime.bash | 4 +-- src/scriptapps/runtime.ps1 | 6 ++-- 7 files changed, 33 insertions(+), 25 deletions(-) diff --git a/bin/runtime.cmd b/bin/runtime.cmd index 50f13aa8..ff6a1e92 100755 --- a/bin/runtime.cmd +++ b/bin/runtime.cmd @@ -432,21 +432,27 @@ SETLOCAL EnableDelayedExpansion @REM batch file library functions @GOTO :endlib -@REM padding -@REM padding -@REM padding -@REM padding +@REM padding xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx +@REM padding xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx %= ---------------------------------------------------------------------- =% @rem courtesy of dbenham :: Example usage @rem call :getUniqueFile "d:\test\myFile" ".txt" myFile @rem echo myFile="%myFile%" - +@rem 2025 - wmic deprecated :/ +@rem 2025 - output of 'wmic os get localDateTime' was something like: +@rem LocalDateTime +@rem 20251015234316.777000+660 +@rem !time! has a resolution of centiseconds. As we test in a loop for file existence, that should be ok. :getUniqueFile baseName extension rtnVar -setlocal +setlocal enabledelayedexpansion :getUniqueFileLoop -for /f "skip=1" %%A in ('wmic os get localDateTime') do for %%B in (%%A) do set "rtn=%~1_%%B%~2" +set "r=!date!_!time!" +set "r=%r::=.%" +set "r=%r: =%" +set "rtn=%~1_!r!%~2" +echo "### %rtn%" if exist "%rtn%" ( goto :getUniqueFileLoop ) else ( @@ -454,6 +460,7 @@ if exist "%rtn%" ( ) endlocal & set "%~3=%rtn%" exit /b + %= ---------------------------------------------------------------------- =% @REM padding @@ -1389,7 +1396,7 @@ case "$1" in ;; "list") if [[ -d "$archdir" ]]; then - echo "$(ls $archdir -1 | wc -l) files in $archdir" + echo "$(ls $archdir -1 | grep -v '_BUILDCOPY$' | wc -l) files in $archdir" echo $(ls $archdir -1) else echo -e "No runtimes available in $archdir\n Use '$0 fetch' to install." @@ -1397,7 +1404,7 @@ case "$1" in ;; "run") #todo - lookup active runtime for os-arch from .toml file - activeruntime=$(ls $archdir -1 | tail -n 1) + activeruntime=$(ls $archdir -1 | grep -v '_BUILDCOPY$' | tail -n 1) activeruntime_fullpath="$archdir/$activeruntime" #echo "using $activeruntime_fullpath" shift @@ -1960,7 +1967,7 @@ function psmain { if (-not(Test-Path -Path $archfolder -PathType Container)) { write-host "No runtimes seem to be installed for $arch`nPlease use 'runtime.cmd fetch' to install" } else { - $dircontents = (get-childItem -Path $archfolder -File | Sort-Object Name) + $dircontents = (get-childItem -Path $archfolder -File | where-object Name -Notlike '*_BUILDCOPY.*' | Sort-Object Name) if ($dircontents.Count -gt 0) { #write-host "run.." write-host "num params: $($PSBoundParameters.opts.count)" @@ -2033,7 +2040,7 @@ function psmain { $localdict = @{} if (test-path -Path $archfolder -Type Container) { - $dircontents = (get-childItem -Path $archfolder -File | Where-object {-not ($(".txt",".tm") -contains $_.Extension) }) + $dircontents = (get-childItem -Path $archfolder -File | Where-object Name -Notlike '*_BUILDCOPY.*' | Where-object {-not ($(".txt",".tm") -contains $_.Extension) }) foreach ($f in $dircontents) { $local_sha1 = Get-FileHash -Path $(${f}.FullName) -Algorithm SHA1 $localdict[$f.Name] = ${local_sha1}.Hash @@ -2086,7 +2093,7 @@ function psmain { if (test-path -Path $archfolder -Type Container) { Write-host "-----------------------------------------------------------------------" Write-Host "Local runtimes for $arch" - $dircontents = (get-childItem -Path $archfolder -File | Where-object {-not ($(".txt",".tm") -contains $_.Extension) }) + $dircontents = (get-childItem -Path $archfolder -File | Where-object Name -Notlike '*_BUILDCOPY.*' | Where-object {-not ($(".txt",".tm") -contains $_.Extension) }) write-host "$(${dircontents}.count) files in $archfolder" Write-host "-----------------------------------------------------------------------" foreach ($f in $dircontents) { @@ -2163,3 +2170,4 @@ no script engine should try to run me + diff --git a/src/make.tcl b/src/make.tcl index 7a4fddc3..f4407148 100644 --- a/src/make.tcl +++ b/src/make.tcl @@ -2636,7 +2636,7 @@ foreach runtime [dict keys $runtime_vfs_map] { } #invoke can fail if runtime not an executable file for the current platform - if {[file type $rtfolder/$runtime] ne "directory"} { + if {[file type $rtfolder/$runtime] eq "directory"} { #assume it's a mounted tclkit (because tcl kits mount in same place as their underlying path and mask the executable) #use the BUILDCOPY created above - REVIEW if {$::tcl_platform(platform) eq "windows"} { @@ -2696,7 +2696,7 @@ foreach runtimefile $runtimes { } #---------------------- - if {[file type $rtfolder/$runtimefile] ne "directory"} { + if {[file type $rtfolder/$runtimefile] eq "directory"} { #assume it's a mounted tclkit (because tcl kits mount in same place as their underlying path and mask the executable) #use the BUILDCOPY created above - REVIEW if {$::tcl_platform(platform) eq "windows"} { diff --git a/src/project_layouts/custom/_project/punk.basic/src/make.tcl b/src/project_layouts/custom/_project/punk.basic/src/make.tcl index 7a4fddc3..f4407148 100644 --- a/src/project_layouts/custom/_project/punk.basic/src/make.tcl +++ b/src/project_layouts/custom/_project/punk.basic/src/make.tcl @@ -2636,7 +2636,7 @@ foreach runtime [dict keys $runtime_vfs_map] { } #invoke can fail if runtime not an executable file for the current platform - if {[file type $rtfolder/$runtime] ne "directory"} { + if {[file type $rtfolder/$runtime] eq "directory"} { #assume it's a mounted tclkit (because tcl kits mount in same place as their underlying path and mask the executable) #use the BUILDCOPY created above - REVIEW if {$::tcl_platform(platform) eq "windows"} { @@ -2696,7 +2696,7 @@ foreach runtimefile $runtimes { } #---------------------- - if {[file type $rtfolder/$runtimefile] ne "directory"} { + if {[file type $rtfolder/$runtimefile] eq "directory"} { #assume it's a mounted tclkit (because tcl kits mount in same place as their underlying path and mask the executable) #use the BUILDCOPY created above - REVIEW if {$::tcl_platform(platform) eq "windows"} { diff --git a/src/project_layouts/custom/_project/punk.project-0.1/src/make.tcl b/src/project_layouts/custom/_project/punk.project-0.1/src/make.tcl index 7a4fddc3..f4407148 100644 --- a/src/project_layouts/custom/_project/punk.project-0.1/src/make.tcl +++ b/src/project_layouts/custom/_project/punk.project-0.1/src/make.tcl @@ -2636,7 +2636,7 @@ foreach runtime [dict keys $runtime_vfs_map] { } #invoke can fail if runtime not an executable file for the current platform - if {[file type $rtfolder/$runtime] ne "directory"} { + if {[file type $rtfolder/$runtime] eq "directory"} { #assume it's a mounted tclkit (because tcl kits mount in same place as their underlying path and mask the executable) #use the BUILDCOPY created above - REVIEW if {$::tcl_platform(platform) eq "windows"} { @@ -2696,7 +2696,7 @@ foreach runtimefile $runtimes { } #---------------------- - if {[file type $rtfolder/$runtimefile] ne "directory"} { + if {[file type $rtfolder/$runtimefile] eq "directory"} { #assume it's a mounted tclkit (because tcl kits mount in same place as their underlying path and mask the executable) #use the BUILDCOPY created above - REVIEW if {$::tcl_platform(platform) eq "windows"} { diff --git a/src/project_layouts/custom/_project/punk.shell-0.1/src/make.tcl b/src/project_layouts/custom/_project/punk.shell-0.1/src/make.tcl index 7a4fddc3..f4407148 100644 --- a/src/project_layouts/custom/_project/punk.shell-0.1/src/make.tcl +++ b/src/project_layouts/custom/_project/punk.shell-0.1/src/make.tcl @@ -2636,7 +2636,7 @@ foreach runtime [dict keys $runtime_vfs_map] { } #invoke can fail if runtime not an executable file for the current platform - if {[file type $rtfolder/$runtime] ne "directory"} { + if {[file type $rtfolder/$runtime] eq "directory"} { #assume it's a mounted tclkit (because tcl kits mount in same place as their underlying path and mask the executable) #use the BUILDCOPY created above - REVIEW if {$::tcl_platform(platform) eq "windows"} { @@ -2696,7 +2696,7 @@ foreach runtimefile $runtimes { } #---------------------- - if {[file type $rtfolder/$runtimefile] ne "directory"} { + if {[file type $rtfolder/$runtimefile] eq "directory"} { #assume it's a mounted tclkit (because tcl kits mount in same place as their underlying path and mask the executable) #use the BUILDCOPY created above - REVIEW if {$::tcl_platform(platform) eq "windows"} { diff --git a/src/scriptapps/runtime.bash b/src/scriptapps/runtime.bash index 986a0b10..251b7277 100644 --- a/src/scriptapps/runtime.bash +++ b/src/scriptapps/runtime.bash @@ -116,7 +116,7 @@ case "$1" in ;; "list") if [[ -d "$archdir" ]]; then - echo "$(ls $archdir -1 | wc -l) files in $archdir" + echo "$(ls $archdir -1 | grep -v '_BUILDCOPY$' | wc -l) files in $archdir" echo $(ls $archdir -1) else echo -e "No runtimes available in $archdir\n Use '$0 fetch' to install." @@ -124,7 +124,7 @@ case "$1" in ;; "run") #todo - lookup active runtime for os-arch from .toml file - activeruntime=$(ls $archdir -1 | tail -n 1) + activeruntime=$(ls $archdir -1 | grep -v '_BUILDCOPY$' | tail -n 1) activeruntime_fullpath="$archdir/$activeruntime" #echo "using $activeruntime_fullpath" shift diff --git a/src/scriptapps/runtime.ps1 b/src/scriptapps/runtime.ps1 index 10422337..bc00d1f2 100644 --- a/src/scriptapps/runtime.ps1 +++ b/src/scriptapps/runtime.ps1 @@ -254,7 +254,7 @@ function psmain { if (-not(Test-Path -Path $archfolder -PathType Container)) { write-host "No runtimes seem to be installed for $arch`nPlease use 'runtime.cmd fetch' to install" } else { - $dircontents = (get-childItem -Path $archfolder -File | Sort-Object Name) + $dircontents = (get-childItem -Path $archfolder -File | where-object Name -Notlike '*_BUILDCOPY.*' | Sort-Object Name) if ($dircontents.Count -gt 0) { #write-host "run.." write-host "num params: $($PSBoundParameters.opts.count)" @@ -327,7 +327,7 @@ function psmain { $localdict = @{} if (test-path -Path $archfolder -Type Container) { - $dircontents = (get-childItem -Path $archfolder -File | Where-object {-not ($(".txt",".tm") -contains $_.Extension) }) + $dircontents = (get-childItem -Path $archfolder -File | Where-object Name -Notlike '*_BUILDCOPY.*' | Where-object {-not ($(".txt",".tm") -contains $_.Extension) }) foreach ($f in $dircontents) { $local_sha1 = Get-FileHash -Path $(${f}.FullName) -Algorithm SHA1 $localdict[$f.Name] = ${local_sha1}.Hash @@ -380,7 +380,7 @@ function psmain { if (test-path -Path $archfolder -Type Container) { Write-host "-----------------------------------------------------------------------" Write-Host "Local runtimes for $arch" - $dircontents = (get-childItem -Path $archfolder -File | Where-object {-not ($(".txt",".tm") -contains $_.Extension) }) + $dircontents = (get-childItem -Path $archfolder -File | Where-object Name -Notlike '*_BUILDCOPY.*' | Where-object {-not ($(".txt",".tm") -contains $_.Extension) }) write-host "$(${dircontents}.count) files in $archfolder" Write-host "-----------------------------------------------------------------------" foreach ($f in $dircontents) {