{"id":44779028,"url":"https://github.com/hyperi-io/macbash","last_synced_at":"2026-03-11T03:05:34.946Z","repository":{"id":337530756,"uuid":"1117865387","full_name":"hyperi-io/macbash","owner":"hyperi-io","description":"CLI tool to check bash scripts for macOS compatibility and auto-fix them for cross-platform portability","archived":false,"fork":false,"pushed_at":"2026-03-02T00:31:46.000Z","size":65,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-02T03:44:30.412Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyperi-io.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-16T23:41:01.000Z","updated_at":"2026-03-02T00:31:48.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/hyperi-io/macbash","commit_stats":null,"previous_names":["hyperi-io/macbash"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/hyperi-io/macbash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperi-io%2Fmacbash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperi-io%2Fmacbash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperi-io%2Fmacbash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperi-io%2Fmacbash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperi-io","download_url":"https://codeload.github.com/hyperi-io/macbash/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperi-io%2Fmacbash/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30368694,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-10T21:41:54.280Z","status":"online","status_checked_at":"2026-03-11T02:00:07.027Z","response_time":84,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-02-16T07:19:48.840Z","updated_at":"2026-03-11T03:05:34.939Z","avatar_url":"https://github.com/hyperi-io.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# macbash\n\n[![CI](https://github.com/hypersec-io/macbash/actions/workflows/ci.yml/badge.svg)](https://github.com/hypersec-io/macbash/actions/workflows/ci.yml)\n[![Go](https://img.shields.io/badge/Go-1.23+-00ADD8?logo=go\u0026logoColor=white)](https://go.dev/)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)\n\nCheck and fix bash scripts so they work on macOS.  \nDetects GNU/Linux-specific bash constructs that won't work on macOS. Can auto-fix many issues.  \n\n## Install\n\n```bash\n# Quick install\ncurl -fsSL https://raw.githubusercontent.com/hypersec-io/macbash/main/packaging/install.sh | sh\n\n# Homebrew\nbrew tap hypersec-io/tools \u0026\u0026 brew install macbash\n\n# Debian/Ubuntu\ncurl -LO https://github.com/hypersec-io/macbash/releases/latest/download/macbash_1.0.0_amd64.deb\nsudo dpkg -i macbash_1.0.0_amd64.deb\n\n# RHEL/Fedora\ncurl -LO https://github.com/hypersec-io/macbash/releases/latest/download/macbash-1.0.0-1.x86_64.rpm\nsudo rpm -i macbash-1.0.0-1.x86_64.rpm\n\n# From source\ngo install github.com/hypersec-io/macbash/cmd/macbash@latest\n```\n\n## Usage\n\n```bash\nmacbash script.sh                        # Check for issues\nmacbash -w script.sh                     # Fix and overwrite in-place\nmacbash -o fixed.sh script.sh            # Fix to new file\nmacbash --format json scripts/*.sh       # JSON output for CI\nmacbash --config custom-rules.yaml *.sh  # Custom rules\n```\n\nExit codes: 0 = clean, 1 = errors, 2 = warnings only\n\n## What It Catches\n\n### GNU Coreutils (Error)\n\n| Issue | Problem | Fix |\n|-------|---------|-----|\n| `sed -i` | BSD requires backup extension | `sed -i ''` or `sed -i.bak` |\n| `grep -P` | Perl regex is GNU-only | `grep -E` (auto-converts simple patterns) |\n| `readlink -f` | GNU-only | `cd/pwd -P` combo |\n| `date -d` | GNU-only date parsing | `date -j -f` on BSD |\n| `stat -c` | GNU format option | `stat -f` on BSD |\n| `xargs -r` | GNU no-run-if-empty | Remove (BSD default) |\n| `find -printf` | GNU-only | `-exec stat` |\n| `sort -V` | GNU version sort | Custom function |\n| `timeout` | GNU coreutils | `gtimeout` via Homebrew |\n\n### Bash 4+ Features (Error)\n\nmacOS ships bash 3.2 (GPLv3 licensing):\n\n| Feature | Version | Alternative |\n|---------|---------|-------------|\n| `declare -A` | 4.0+ | Indexed arrays |\n| `${var,,}` `${var^^}` | 4.0+ | `tr` |\n| `mapfile`/`readarray` | 4.0+ | while-read loop |\n| `\\|\u0026` | 4.0+ | `2\u003e\u00261 \\|` |\n| `${arr[-1]}` | 4.3+ | `${arr[${#arr[@]}-1]}` |\n\n### Portability (Warning/Info)\n\n| Issue | Severity | Fix |\n|-------|----------|-----|\n| `echo -e` | Warning | `printf \"%b\"` |\n| `echo -n` | Info | `printf \"%s\"` |\n| `#!/bin/bash` | Info | `#!/usr/bin/env bash` |\n| `gawk` | Warning | `awk` |\n\n## Custom Rules\n\n```yaml\nversion: \"1.0\"\nrules:\n  - id: my-rule\n    name: \"Custom check\"\n    description: \"What this catches\"\n    severity: warning\n    pattern: 'some\\s+pattern'\n    negative_pattern: 'exclude\\s+this'\n    fix_type: suggest\n    fix_template: \"Use this instead\"\n    tags: [custom]\n```\n\n## CI Integration\n\n```yaml\n- name: Check bash portability\n  run: |\n    go install github.com/hypersec-io/macbash/cmd/macbash@latest\n    macbash scripts/*.sh\n```\n\nJSON output for reporting:\n\n```json\n{\n  \"total_issues\": 2,\n  \"errors\": 1,\n  \"warnings\": 1,\n  \"matches\": [\n    {\n      \"file\": \"script.sh\",\n      \"line\": 5,\n      \"rule_id\": \"grep-perl-regex\",\n      \"severity\": \"error\",\n      \"content\": \"grep -P '\\\\d+' file.txt\",\n      \"fix\": \"grep -E or perl -ne\"\n    }\n  ]\n}\n```\n\n## Development\n\n```bash\ngo build ./cmd/macbash\ngo test ./...\ngolangci-lint run\n```\n\n## License\n\nApache-2.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperi-io%2Fmacbash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperi-io%2Fmacbash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperi-io%2Fmacbash/lists"}