Skip to content

fix: ensure shell scripts are portable across macOS and Linux#192

Merged
palazzem merged 3 commits intomainfrom
palazzem/update-init
Jan 16, 2026
Merged

fix: ensure shell scripts are portable across macOS and Linux#192
palazzem merged 3 commits intomainfrom
palazzem/update-init

Conversation

@palazzem
Copy link
Copy Markdown
Owner

@palazzem palazzem commented Jan 16, 2026

Related Issues

  • N/A

Proposed Changes:

This PR addresses shell script portability issues between macOS and Linux by replacing GNU-specific tools with POSIX-compliant alternatives:

  • scripts/download_fixtures.sh:

    • Replaced sed -i with perl -pi -e for in-place file editing and added proper variable quoting throughout the script. The sed -i command has different syntax on macOS (requires a backup extension argument) versus GNU sed, causing failures in macOS environments.
    • Added extraction of script/hassfest module (only __init__.py and model.py files) required for running Home Assistant tests. Imports are rewritten from script. to tests.script. to match the new location.
    • Optimized the script to use a single tar extraction for both tests/ and script/ folders, and a single find command for import rewriting using regex capture groups.
  • .github/workflows/testing.yaml and README.md: Replaced grep -Po (GNU grep with Perl regex) with portable sed command using POSIX extended regex. The -Po flags are not available in BSD grep (macOS default).

  • .python-version: Added Python version file to specify the project's Python version (3.13) for use with version management tools like pyenv.

These changes ensure that initialization and fixture download scripts run successfully on both macOS and Linux without modification.

Testing:

The existing CI pipeline (GitHub Actions) will validate these changes across the Linux environment. Manual verification can be performed on macOS systems where the scripts previously failed due to incompatible sed syntax.

Extra Notes (optional):

The changes maintain backward compatibility and do not alter the functional behavior of any scripts—only the tools used to accomplish the same tasks in a cross-platform manner.

Checklist

  • Related issues and proposed changes are filled
  • Tests are defining the correct and expected behavior
  • Code is well-documented via docstrings

@palazzem palazzem self-assigned this Jan 16, 2026
@palazzem palazzem added this to the 2.5.2 milestone Jan 16, 2026
@palazzem palazzem merged commit 796a44b into main Jan 16, 2026
3 of 4 checks passed
@palazzem palazzem deleted the palazzem/update-init branch January 16, 2026 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant