diff --git a/scripts/explorer-media-rename.ps1 b/scripts/explorer-media-rename.ps1 index 46324db..0e69a34 100644 --- a/scripts/explorer-media-rename.ps1 +++ b/scripts/explorer-media-rename.ps1 @@ -149,14 +149,21 @@ function Invoke-Action([string]$itemAction, [string]$target) { $runnerPath = Join-Path $PSScriptRoot $plan.Runner $tokens = @($target) + $plan.Extra - # 注意:必须 Out-Host 把子脚本的输出导到控制台, - # 否则它会混进本函数的返回值,调用方拿到的就不是退出码了。 - if ($DryRun) { & $runnerPath -Tokens $tokens -DryRun | Out-Host } - else { & $runnerPath -Tokens $tokens | Out-Host } + # 关键:用独立子进程「继承当前控制台」来跑,而不是在进程内 + 管道。 + # 管道会让远端 ssh -t 的交互提示与本地输入回显错位(提示行会消失)。 + $quotedTokens = ($tokens | ForEach-Object { "'" + ($_ -replace "'", "''") + "'" }) -join ',' + $quotedRunner = "'" + ($runnerPath -replace "'", "''") + "'" + $extra = '' + if ($DryRun) { $extra = ' -DryRun' } + $command = "& $quotedRunner -Tokens @($quotedTokens)$extra" - $code = $LASTEXITCODE - if ($null -eq $code -or $code -is [array]) { return 0 } - return [int]$code + $proc = Start-Process -FilePath $PwshPath ` + -ArgumentList @('-NoLogo', '-NoProfile', '-ExecutionPolicy', 'Bypass', + '-Command', ('"' + $command + '"')) ` + -NoNewWindow -Wait -PassThru + + if ($null -eq $proc) { return 1 } + return [int]$proc.ExitCode } # ---------------------------------------------------------------- worker 模式 @@ -171,7 +178,8 @@ function Invoke-Worker { } try { $Host.UI.RawUI.WindowTitle = 'SceneMarshal 队列' } catch { } - Write-WorkerLog 'worker 启动' + Write-WorkerLog ("worker 启动(stdin重定向={0} stdout重定向={1})" -f ` + [Console]::IsInputRedirected, [Console]::IsOutputRedirected) Write-Host '📋 SceneMarshal 队列已启动(空闲 20 秒后自动关闭)' -ForegroundColor Cyan Write-Host '' diff --git a/scripts/media_archive.py b/scripts/media_archive.py index a465afe..55981a1 100644 --- a/scripts/media_archive.py +++ b/scripts/media_archive.py @@ -426,7 +426,7 @@ def main() -> int: category = choose_category(cats, suggestion) if not category: print("已取消。") - return 0 + return 2 # 用非 0 退出码,避免上层把「取消」当成「成功」 dest = MEDIA_ROOT / category / src.name merging = dest.exists() and not args.no_merge @@ -460,7 +460,7 @@ def main() -> int: confirm = "n" if confirm not in {"", "y", "yes"}: print("已取消。") - return 0 + return 2 # 同上:取消不能报成成功 if merging: rep = merge_into(src, dest)