From 4adfc9d0bf9d84685bf1139a5f34e0c2fa82cef7 Mon Sep 17 00:00:00 2001 From: Josh Rogers Date: Fri, 8 May 2026 23:13:57 -0500 Subject: [PATCH] Fix dev-db.ps1 status to exit cleanly when container is absent docker inspect exits non-zero when the container is missing; under $ErrorActionPreference='Stop' that propagated and made `dev-db.ps1 status` exit 1 even though the script printed the right output. Swallow the inner exit code locally so callers see exit 0. --- scripts/dev-db.ps1 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/scripts/dev-db.ps1 b/scripts/dev-db.ps1 index 390403b..cc397f5 100644 --- a/scripts/dev-db.ps1 +++ b/scripts/dev-db.ps1 @@ -34,8 +34,13 @@ $Image = 'postgres:17' $ConnectionString = 'Host=localhost;Database=yeschef;Username=yeschef;Password=yeschef' function Get-ContainerState { - $state = docker inspect --format '{{.State.Status}}' $Name 2>$null - if ($LASTEXITCODE -ne 0) { return 'absent' } + # docker inspect exits non-zero when the container is missing; swallow + # that so $ErrorActionPreference='Stop' doesn't abort the script and + # so the caller's exit code stays clean. + $state = & docker inspect --format '{{.State.Status}}' $Name 2>$null + $code = $LASTEXITCODE + $global:LASTEXITCODE = 0 + if ($code -ne 0) { return 'absent' } return $state }