From ccf4d623c938f80dd305977967924a4682ca2c27 Mon Sep 17 00:00:00 2001 From: Matti Airas Date: Sat, 22 Nov 2025 01:25:45 +0200 Subject: [PATCH] fix(ci): handle grep exit code 1 when .env contains only comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- run | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/run b/run index aa5114e..c249acc 100755 --- a/run +++ b/run @@ -91,23 +91,14 @@ function build-deb { # Set up environment dev-env - echo "DEBUG: dev-env completed" # Check if changelog was already generated by CI (shared-workflows) # If debian/changelog exists and was modified in the last 5 minutes, skip regeneration - echo "DEBUG: Checking debian/changelog..." - echo "DEBUG: PWD=$(pwd)" - echo "DEBUG: ls -la debian/changelog: $(ls -la debian/changelog 2>&1 || echo 'file not found')" - if [ -f "debian/changelog" ]; then - echo "DEBUG: debian/changelog exists, checking age..." # Use stat -c for Linux, stat -f for macOS, handle errors gracefully CHANGELOG_MTIME=$(stat -c %Y debian/changelog 2>/dev/null) || CHANGELOG_MTIME=$(stat -f %m debian/changelog 2>/dev/null) || CHANGELOG_MTIME=0 - echo "DEBUG: CHANGELOG_MTIME=$CHANGELOG_MTIME" CURRENT_TIME=$(date +%s) - echo "DEBUG: CURRENT_TIME=$CURRENT_TIME" CHANGELOG_AGE=$((CURRENT_TIME - CHANGELOG_MTIME)) - echo "DEBUG: CHANGELOG_AGE=$CHANGELOG_AGE" if [ "$CHANGELOG_AGE" -lt 300 ]; then echo "📋 Using existing debian/changelog (generated by CI)" else @@ -122,11 +113,8 @@ function build-deb { --force-distribution \ "Automated release $PACKAGE_VERSION. See GitHub for details." fi - else - echo "DEBUG: debian/changelog does not exist" fi - echo "DEBUG: About to run dpkg-buildpackage..." dpkg-buildpackage -us -uc -b echo "✅ Debian package built successfully" @@ -427,7 +415,8 @@ function _export_unset { # Need to use a temp file to avoid a subshell local tmpfile=$(mktemp) - grep -v '^#' $file >$tmpfile + # Use || true to handle files with only comments (grep returns 1 when no matches) + grep -v '^#' "$file" >"$tmpfile" || true while read -r line; do if [[ ! "$line" =~ ^[[:space:]]*$ ]]; then