Skip to content

The agent that grows with you

fix(desktop): join split try/catch in Windows SSH probe for PowerShell 5.1

wa19390ceafba79992
diff --git a/apps/desktop/electron/windows-remote-lifecycle.ts b/apps/desktop/electron/windows-remote-lifecycle.ts
index c1e21cc5279..6d74b082382 100644
--- a/apps/desktop/electron/windows-remote-lifecycle.ts
+++ b/apps/desktop/electron/windows-remote-lifecycle.ts
@@ -28,8 +28,7 @@ async function probeWindowsRemote(ssh, explicitHermesPath = '') {
'if([string]::IsNullOrWhiteSpace($candidate)){return}',
'$current=[IO.Path]::GetFullPath($candidate);$first=$true',
'while($true){',
- 'try{$item=Get-Item -LiteralPath $current -Force -ErrorAction Stop}',
- 'catch [Management.Automation.ItemNotFoundException]{if(-not $allowMissing -and $first){throw "Path was not found: $candidate"};$parent=[IO.Path]::GetDirectoryName($current);if(-not $parent -or $parent -eq $current){break};$current=$parent;$first=$false;continue}',
+ 'try{$item=Get-Item -LiteralPath $current -Force -ErrorAction Stop}catch [Management.Automation.ItemNotFoundException]{if(-not $allowMissing -and $first){throw "Path was not found: $candidate"};$parent=[IO.Path]::GetDirectoryName($current);if(-not $parent -or $parent -eq $current){break};$current=$parent;$first=$false;continue}',
'if(($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0){throw "Path contains a link or reparse point: $current"}',
'$parent=$item.Parent.FullName;if(-not $parent -or $parent -eq $current){break};$current=$parent;$first=$false',
'}',
@@ -91,8 +90,7 @@ public static class HermesMarkerNoFollow {
'if([string]::IsNullOrWhiteSpace($candidate)){return}',
'$current=[IO.Path]::GetFullPath($candidate);$first=$true',
'while($true){',
- 'try{$item=Get-Item -LiteralPath $current -Force -ErrorAction Stop}',
- 'catch [Management.Automation.ItemNotFoundException]{if(-not $allowMissing -and $first){throw "Path was not found: $candidate"};$parent=[IO.Path]::GetDirectoryName($current);if(-not $parent -or $parent -eq $current){break};$current=$parent;$first=$false;continue}',
+ 'try{$item=Get-Item -LiteralPath $current -Force -ErrorAction Stop}catch [Management.Automation.ItemNotFoundException]{if(-not $allowMissing -and $first){throw "Path was not found: $candidate"};$parent=[IO.Path]::GetDirectoryName($current);if(-not $parent -or $parent -eq $current){break};$current=$parent;$first=$false;continue}',
'if(($item.Attributes -band [IO.FileAttributes]::ReparsePoint) -ne 0){throw "Path contains a link or reparse point: $current"}',
'$parent=$item.Parent.FullName;if(-not $parent -or $parent -eq $current){break};$current=$parent;$first=$false',
'}',