Skip to content
This repository was archived by the owner on Feb 15, 2026. It is now read-only.

Comments

fix(ci): handle grep exit code 1 when .env contains only comments#43

Merged
mairas merged 1 commit intomainfrom
fix/grep-no-match
Nov 21, 2025
Merged

fix(ci): handle grep exit code 1 when .env contains only comments#43
mairas merged 1 commit intomainfrom
fix/grep-no-match

Conversation

@mairas
Copy link
Contributor

@mairas mairas commented Nov 21, 2025

Summary

  • Fix _export_unset function failing when .env contains only comments
  • Remove debug statements from previous commit

Root Cause

The CI workflow creates .env with a single comment line:

echo "# Environment file for GitHub Actions" > .env

When _export_unset runs grep -v '^#' on this file:

  1. No lines match (all lines are comments)
  2. grep returns exit code 1 (no matches found)
  3. With set -o errexit, exit code 1 causes the script to exit immediately

This is why the build-deb step was failing in 0.002 seconds right after printing "🗝️ Setting environment from .env and .env.defaults".

Solution

Add || true to the grep command:

grep -v '^#' "$file" >"$tmpfile" || true

This allows the command to succeed even when grep finds no matches.

Test plan

  • PR checks pass
  • After merge, main branch workflow succeeds (finally!)

🤖 Generated with Claude Code

The _export_unset function was failing in CI because grep -v '^#'
returns exit code 1 when no lines match (file contains only comments).
With set -o errexit, this caused the script to exit immediately.

The CI workflow creates .env with just a comment line:
  # Environment file for GitHub Actions

When _export_unset tries to grep out comments, no lines match, and
grep exits with code 1, terminating the script.

Fix: Add || true to the grep command to ignore the no-match exit code.

Also removed debug statements from the previous commit.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@mairas mairas merged commit d4acf4a into main Nov 21, 2025
1 check passed
@mairas mairas deleted the fix/grep-no-match branch November 21, 2025 23:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant