← Back to Pull requests

ROSAENG-66712 | fix: replace non-portable sed -i with redirect-and-move #184

Closed
unknown closed this pull request without merging on Sep 10, 2026 15:46 UTC
View on GitHub
unknown unknown commented on Sep 10, 2026 04:10 UTC
Author

PR Summary

Replace all non-portable GNU-isms in the Makefile with POSIX-compatible alternatives, fixing macOS compatibility across all targets.

Detailed Description of the Issue

The Makefile uses several GNU-specific constructs that fail on macOS:

1. sed -i — BSD sed requires a backup extension argument while GNU sed does not, causing invalid command code errors on macOS.
2. readlink -f — GNU coreutils extension not available on macOS.
3. *\s in sed patterns* — GNU sed extension, not POSIX-portable.

Additionally, in the verify target, sed and mv were chained with &&. Bash exempts the left-hand side of an && list from set -e, so a sed failure would silently allow terraform validate to run against the unmodified file. The maintainer utility targets had no set -e at all.

Related Issues and PRs

  • Fixes: ROSAENG-66712

  • Related PR(s): terraform-redhat/terraform-rhcs-rosa-hcp#189

  • Related design/docs: N/A
  • Type of Change

  • feat - adds a new module capability or new user-facing behavior.

  • fix - resolves incorrect module behavior or bug.

  • docs - updates documentation only.

  • style - formatting/naming changes with no logic impact.

  • refactor - module code restructuring with no behavior change.

  • test - adds or updates tests only.

  • chore - maintenance work (tooling, housekeeping, non-product code).

  • build - changes build system, packaging, or dependencies for build output.

  • ci - changes CI pipelines, jobs, or automation workflows.

  • perf - improves performance without changing intended behavior.
  • Previous Behavior

  • make verify and make pre-push-checks fail on macOS with sed: invalid command code e.

  • readlink -f in the verify target fails on macOS (not a GNU coreutils system).

  • Maintainer utility targets (dev-environment, registry-environment, change-ocp-version, change-module-version) also fail on macOS due to sed -i.

  • change-module-version uses \s (GNU sed extension) which may not match whitespace on non-GNU systems.

  • In the verify target, a sed failure is silently swallowed because set -e does not apply to the left-hand side of && lists, allowing terraform validate to run against the unmodified pinned version instead of the floor version.

  • Maintainer utility targets lack set -e, so a failed sed does not stop the loop.
  • Behavior After This Change

  • All Makefile targets run successfully on both macOS (BSD sed) and Linux (GNU sed).

  • readlink -f replaced with portable cd && pwd.

  • \s replaced with POSIX [[:space:]].

  • In the verify target, sed and mv are separate ;-terminated commands so set -e catches either failure before terraform validate runs.

  • Maintainer utility targets use set -e with separated sed/mv commands for the same error-propagation guarantee.
  • How to Test (Step-by-Step)

    Preconditions

  • macOS or Linux

  • Terraform installed

  • RHCS provider credentials configured
  • Test Steps

    1. Run make verify on macOS (BSD sed)
    2. Confirm all examples validate at both pinned and floor AWS provider versions
    3. Run make pre-push-checks to confirm the full gate passes
    4. Verify make dev-environment switches provider source to terraform.local/local/rhcs
    5. Verify make registry-environment switches it back to terraform-redhat/rhcs

    Expected Results

  • No sed or readlink errors on any platform

  • All example validations pass at both pinned and floor versions

  • Maintainer utility targets complete without error
  • Proof of the Fix

  • Screenshots:

  • Videos:

  • Logs/CLI output:

  • Other artifacts:
  • Breaking Changes

  • No breaking changes

  • Yes, this PR introduces a breaking change (describe impact and migration plan below)
  • Breaking Change Details / Migration Plan

    N/A

    Developer Verification Checklist

  • AWS-only changes: If this PR is mainly AWS-only (no rhcs resources/variables), I linked official Red Hat or cited ROSA HCP documentation that supports reference alignment, or I explained why the change still belongs in-repo per [developer-docs/submodules.md](developer-docs/submodules.md).

  • I checked if this affects terraform-rhcs-rosa-hcp and submitted (or already submitted) a companion PR when needed.

  • Commit subject/title follows [JIRA-TICKET] | [TYPE]: <MESSAGE>.

  • PR description clearly explains both what changed and why.

  • Relevant Jira/GitHub issues and related PRs are linked.

  • Tests were added/updated where appropriate.

  • I manually tested the change.

  • make pre-push-checks passes (or each step: verify, verify-gen, lint, unit-tests, license-check, docs-lint).

  • Documentation was added/updated where appropriate (see make terraform-docs).

  • Any risk, limitation, or follow-up work is documented.
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->

    Summary by CodeRabbit

    Chores

  • Verification and version-editing workflows now use more portable path handling and safer temporary-file replacement.

  • Existing configuration substitutions and validation behavior remain unchanged.

  • Verification continues to restore the original configuration after completion.

  • <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: michaelryanmcneill Review duration: 696m
    All Vouch review confidence checks passed
    Residual risk 0.22 = Change Risk (0.52) × (1 − Review Confidence (0.57)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    56%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #184"
    general weight: 0.35
    Assignees
    Unassigned
    Labels
    risk: low confidence: 56.8% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 56.8% · Lower = rushed or shallow review
    56.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.5% · Safe to merge
    22.5%