fix: surface podman errors instead of aborting silently
`set -e` aborted build.sh when `podman image rm`/`prune` failed, and `2>/dev/null` hid the reason, so --remove exited 125 with no output. Combining --remove --prune also skipped the prune. Guard the removal with `podman image exists` for a clear "nothing to remove", drop `2>/dev/null` so podman's reason is visible, and use `cmd || echo` to warn without aborting. Exit status stays 0 on failure by design.
This commit is contained in:
@@ -42,10 +42,14 @@ fi
|
||||
|
||||
if ((REMOVE || PRUNE)); then
|
||||
if ((REMOVE)); then
|
||||
podman image rm "${IMAGE}" 2>/dev/null
|
||||
if podman image exists "$IMAGE"; then
|
||||
podman image rm "${IMAGE}" || echo "WARNING: could not remove $IMAGE" >&2
|
||||
else
|
||||
echo "$IMAGE does not exist, nothing to remove"
|
||||
fi
|
||||
fi
|
||||
if ((PRUNE)); then
|
||||
podman image prune -f 2>/dev/null
|
||||
podman image prune -f || echo "WARNING: prune failed" >&2
|
||||
fi
|
||||
exit 0
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user