Fix shell script hygiene: shebang, pipefail, quoting, SC2155; add ShellCheck CI#5
Conversation
- macos/install.sh: fix shebang (#!/bin/sh -> #!/usr/bin/env bash),
add pipefail, quote $CONFIG_HOME vars, use ${BASH_SOURCE[0]}
- omarchy/install.sh: separate readonly SCRIPT_DIR declaration from
assignment to avoid masking return values (SC2155)
- .github/workflows/shellcheck.yml: new CI job to run ShellCheck on
push and pull_requests
Co-authored-by: eapolinario <653394+eapolinario@users.noreply.github.com>
|
@copilot , what's up with the Shell lint errors in CI? |
.zshrc and .p10k.zsh are Zsh config files that ShellCheck can't parse (SC2148 no-shebang, SC1073/SC1072 parse errors). Use ignore_paths to skip that directory. Co-authored-by: eapolinario <653394+eapolinario@users.noreply.github.com>
The action was scanning |
There was a problem hiding this comment.
Pull request overview
This PR improves shell script hygiene across the repository and introduces a ShellCheck CI workflow to enforce these standards going forward. It fixes several common shell scripting issues flagged by ShellCheck (SC2155, missing pipefail, unquoted variables, wrong shebang) and adds automated linting on every push and PR.
Changes:
- Fix
macos/install.sh: upgrade shebang to#!/usr/bin/env bash, addpipefail, quote all variable expansions, use${BASH_SOURCE[0]}instead of$0 - Fix
omarchy/install.sh: separatereadonly SCRIPT_DIRfrom the command-substitution assignment to avoid masking the subshell exit code (SC2155) - Add
.github/workflows/shellcheck.yml: new CI job usingludeeus/action-shellcheck@2.0.0, excludingmacos/zshto avoid Zsh-syntax parse errors
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
macos/install.sh |
Corrects shebang, adds pipefail, uses ${BASH_SOURCE[0]}, and properly quotes all variable expansions |
omarchy/install.sh |
Splits readonly SCRIPT_DIR from its command-substitution assignment to avoid masking exit codes (SC2155) |
.github/workflows/shellcheck.yml |
New CI workflow that runs ShellCheck on all shell scripts, excluding macos/zsh to skip Zsh-only config files |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| with: | ||
| check_together: 'yes' | ||
| severity: warning | ||
| ignore_paths: macos/zsh |
There was a problem hiding this comment.
The ignore_paths: macos/zsh exclusion is broader than necessary. While it correctly skips .zshrc and .p10k.zsh (Zsh-specific files that ShellCheck cannot parse), it also silently drops macos/zsh/.lessfilter.sh from the ShellCheck scan — a valid #!/usr/bin/env bash script that should be linted.
A more precise approach would be to keep the whole macos/zsh directory in scope and instead add inline # shellcheck shell=bash directives (or # shellcheck disable annotations) to the Zsh config files, or use the ignore_files input to exclude only the specific files (.zshrc, .p10k.zsh). Alternatively, moving .lessfilter.sh out of macos/zsh/ into its own directory would let the exclusion be exact.
| ignore_paths: macos/zsh | |
| ignore_files: macos/zsh/.zshrc macos/zsh/.p10k.zsh |
macos/install.shshebang,pipefail, quoting,${BASH_SOURCE[0]}omarchy/install.shSC2155 — separatereadonlyfrom assignment.github/workflows/shellcheck.yml— CI ShellCheck jobmacos/zshfrom ShellCheck scan —.zshrcand.p10k.zshare Zsh config files that ShellCheck cannot parse✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.