Repository navigation
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Enforces symlink-safe in-place edits by standardizing on sed -i --follow-symlinks and adding a CI-style shell test to prevent regressions.
Changes:
- Added a shell test that flags
sed -iusages missing--follow-symlinksinbin/andmigrations/(with an allowlist). - Updated multiple scripts and migrations to use
sed -i --follow-symlinks. - Documented the rule in contributor/agent guidance docs.
Reviewed changes
Copilot reviewed 11 out of 27 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/shell.d/sed-follow-symlinks-test.sh | New test to detect non-symlink-safe sed -i usage in relevant paths. |
| migrations/1786782461.sh | Use --follow-symlinks when fixing foot.ini. |
| migrations/1786380259.sh | Use --follow-symlinks for main.conf edit. |
| migrations/1785944594.sh | Use --follow-symlinks for limine.conf edit. |
| migrations/1785273276.sh | Use --follow-symlinks for mkinitcpio/modules config edits. |
| migrations/1784818437.sh | Use --follow-symlinks when inserting PAM gate. |
| migrations/1784476564.sh | Use --follow-symlinks when editing hooks config. |
| migrations/1784401744.sh | Use --follow-symlinks for tmux config edits. |
| migrations/1780057136.sh | Use --follow-symlinks for Alacritty/Ghostty config edits. |
| bin/omarchy-toggle-hybrid-gpu | Preserve symlinks when editing /etc/supergfxd.conf. |
| bin/omarchy-setup-security-fingerprint | Preserve symlinks when editing PAM files. |
| bin/omarchy-setup-security-fido2 | Preserve symlinks when editing PAM files. |
| bin/omarchy-restart-audio | Preserve symlinks when editing WirePlumber state files. |
| bin/omarchy-remove-service-sunshine | Preserve symlinks when editing Hyprland autostart file. |
| bin/omarchy-remove-security-fingerprint | Preserve symlinks when removing PAM entries. |
| bin/omarchy-remove-security-fido2 | Preserve symlinks when removing PAM entries. |
| bin/omarchy-plugin-clone | Preserve symlinks when rewriting plugin references. |
| bin/omarchy-install-gaming-retroarch | Preserve symlinks when editing RetroArch config. |
| bin/omarchy-install-gaming-lutris | Preserve symlinks when patching Lutris shebang. |
| bin/omarchy-install-dev-env | Preserve symlinks when enabling PHP extensions. |
| bin/omarchy-hyprland-monitor-scaling | Preserve symlinks when editing monitors.lua. |
| bin/omarchy-hibernation-setup | Preserve symlinks when editing hibernation drop-in. |
| bin/omarchy-hibernation-remove | Preserve symlinks when editing /etc/fstab. |
| bin/omarchy-font-set | Preserve symlinks when editing terminal configs. |
| bin/omarchy-display-text-size | Preserve symlinks when editing terminal configs. |
| agents/skills/migrations.md | Documented sed -i --follow-symlinks requirement + referenced enforcing test. |
| AGENTS.md | Added “Symlink-safe file editing” guidance and pointed to enforcing test. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
cf127ee to
bf0f387
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 11 out of 27 changed files in this pull request and generated no new comments.
Suppressed comments (2)
test/shell.d/sed-follow-symlinks-test.sh:35
- The
grep -v -- '--follow-symlinks'filter is overly broad and can cause false negatives (e.g., a violatingsed -iline that merely mentions--follow-symlinksin an inline comment or string literal will be excluded). Prefer doing the--follow-symlinkscheck inside the loop against the code portion of the line (e.g., strip inline comments first), and only add a violation when the actualsedinvocation lacks the flag.
while IFS=: read -r file lineno line; do
local_line="${line#"${line%%[![:space:]]*}"}"
[[ $local_line == \#* ]] && continue
is_allowlisted "$file" && continue
violations+=("${file#$ROOT/}:$lineno")
done < <(grep -rEn 'sed[[:space:]]+-i([[:space:]]|$)' "$ROOT/bin" "$ROOT/migrations" | grep -v -- '--follow-symlinks' || true)
test/shell.d/sed-follow-symlinks-test.sh:15
- The allowlist entries are currently undocumented, but the header comment implies these are safe because they operate on temp/staging directories. Adding a brief comment per allowlisted path explaining why bare
sed -iis acceptable there will make future maintenance/audits much easier.
ALLOWLIST=(
bin/omarchy-dev-pkg-test
bin/omarchy-plymouth-set
bin/omarchy-upgrade-to-quattro
)
|
Still reproduces on #10605 ( That commit is also what put this PR into conflict. Merging current
The first two are just the Kitty lines that this PR and #10605 both rewrote, so the resolution is mechanical. Worth noting why this one bites harder than most: the failure is silent and points the wrong way. Minimal repro: tmp=$(mktemp -d); mkdir -p "$tmp/repo" "$tmp/cfg"
printf 'family = "Old"\n' >"$tmp/repo/alacritty.toml"
ln -s "$tmp/repo/alacritty.toml" "$tmp/cfg/alacritty.toml"
# bin/omarchy-font-set:30, verbatim
sed -i 's/family = ".*"/family = "New"/g' "$tmp/cfg/alacritty.toml"
test -L "$tmp/cfg/alacritty.toml" && echo "link kept" || echo "link destroyed"
cat "$tmp/repo/alacritty.toml" # still family = "Old"#7625 is the same bug reported from the user side against Happy to push a rebase if that would help move this along. |
Without --follow-symlinks, GNU sed writes a temp file and renames it over the target, replacing any symlink with a regular file. This silently breaks dotfile setups that symlink configs from a version-controlled repository (GNU Stow, chezmoi, yadm, etc.). Every sed -i call across bin/ and migrations/ now includes --follow-symlinks. The flag is harmless on regular files and critical on symlinks, so there is no reason to omit it. An architectural test (test/shell.d/sed-follow-symlinks-test.sh) enforces the rule in CI — any new bare sed -i in bin/ or migrations/ will fail the build. Agent instructions in AGENTS.md and agents/skills/migrations.md are updated with the guidance.
bf0f387 to
41b0498
Compare
|
Thanks, I've rebased 👍 |
omarchy-install-dev-env no longer edits php.ini on quattro (PHP moved to mise), so the conflict resolves to quattro's side. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…anch Six in-place edits landed on quattro after this branch was cut, and sed-follow-symlinks-test fails on each once the two are merged. The xcompose and mise edits touch files under the home directory, exactly where a dotfile manager's symlink lives. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ow-symlinks Both tests pin the exact sed command line, so they reject the flag this branch adds everywhere. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The removal only reaches sed when the host's PAM files carry pam_u2f.so, so the old four-argument pin passed on machines without FIDO2 and failed on those with it. Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-Authored-By: Codex Medium <[email protected]>
|
Reviewed and verified at 13444f3 against The bug is real. On a fresh Omarchy worker, with What I pushed to your branch (merge commits, no rebase or force push):
Tests, on the worker: Second opinion: Codex Medium reviewed the branch over three rounds. It found the stale stub in Some things are left as they are, for you or the maintainer to decide, because none of them breaks anything today:
This now waits on the maintainer. |
|
What I pushed to your branch (a merge commit and two small commits, no rebase or force push):
Tests, on a fresh Omarchy worker: the reproduction still holds against the new base. With Second opinion: none this time. The day's budget of reviews had run out, so these new commits have only had one model's review (Claude Opus 5.5). For that reason this is labelled #7625 reports the same symlink problem from a user's side for The three points from the last comment still stand for you or the maintainer to decide: the lint misses This waits on a second-opinion review, then on the maintainer. |
[High impact] The PR appears safe to merge, with three previous lower-impact findings still open. Findings
SummaryAdds
Reviews (4) · Last reviewed commit: "Merge quattro into fix/sed-follow-symlin..." · Reviewed by Greptile |
| [[ $local_line == \#* ]] && continue | ||
| is_allowlisted "$file" && continue | ||
| violations+=("${file#$ROOT/}:$lineno") | ||
| done < <(grep -rEn 'sed[[:space:]]+-i([[:space:]]|$)' "$ROOT/bin" "$ROOT/migrations" | grep -v -- '--follow-symlinks' || true) |
There was a problem hiding this comment.
The search misses valid in-place commands such as sed -Ei '...' "$config" and sed -i.bak '...' "$config". Both can replace a symlink, but neither matches this pattern. Future unsafe config edits can therefore pass unnoticed. Match combined options and backup suffixes too, and add fixtures for these forms.
# Conflicts: # bin/omarchy-hyprland-monitor-scaling quattro moved monitor scale persistence out of this script into omarchy-hyprland-monitor-persist, which writes its own state file rather than monitors.lua, so quattro's side is taken and the two sed -i calls this branch flagged are gone. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…st merge omarchy-kernel, omarchy-locale-generate and migrations 1790984700, 1791769486 and 1791898365 arrived with bare sed -i, which sed-follow-symlinks-test.sh fails on. Their targets are root-owned (/etc/default/limine, /etc/locale.gen, the limine config and drop-in), and the root runs of both commands ignore path overrides, so following a link there only reaches where root put it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
From omacom#14343: link the stock alacritty, Ghostty and foot configs from a dotfiles directory, run the real omarchy-font-set and omarchy-display-text-size, and check the links survive and the edits land in their targets. sed-follow-symlinks-test.sh only checks the flag is spelled; this fails on quattro for the reason the fix exists. It extends the test that already drives both commands rather than adding a file. Co-Authored-By: Ali Yahya <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]> Co-Authored-By: Codex Medium <[email protected]>
|
What I pushed to your branch (no rebase or force push):
Tests, on a fresh Omarchy worker:
Second opinion: Codex Medium and muse-wonder (pi, thinking high) both reviewed this head and found no runtime defect in the new commits or the rest of the change, and found no Before merging, the maintainer also has two scope questions to decide. This branch edits migrations that have already shipped, which This is |
| # hardware-auth (gate / pam_fprintd / pam_u2f) lines exactly as they are. | ||
| # sed -i renames a complete file into place, so an interrupted run never leaves polkit-1 truncated. | ||
| if ! sudo sed -i -E 's/^(auth|account|password|session)([[:space:]]+)required[[:space:]]+pam_unix\.so[[:space:]]*$/\1\2include system-auth/' "$polkit"; then | ||
| if ! sudo sed -i --follow-symlinks -E 's/^(auth|account|password|session)([[:space:]]+)required[[:space:]]+pam_unix\.so[[:space:]]*$/\1\2include system-auth/' "$polkit"; then |
There was a problem hiding this comment.
Backups lose the original contents
If /etc/pam.d/polkit-1 is a symlink, cp -a saves another link to the same target, not a copy of its contents. The new --follow-symlinks edit changes that target, so the advertised backup contains the edited contents too. Copying it back cannot undo the change.
The /etc/fstab backups in both hibernation commands have the same problem. Copy the target's contents when making these backups so users can recover the original file.
With sed --follow-symlinks the edit lands on the link's target, so a cp -a backup, which copies the link itself, aliases the edited file and cannot restore the original. cp -aL copies the target's contents; on a regular file it behaves exactly as cp -a. Raised by Greptile. Co-Authored-By: Claude Opus 5.5 <[email protected]>
| @@ -0,0 +1,43 @@ | |||
| #!/bin/bash | |||
|
|
|||
| source "$(dirname "${BASH_SOURCE[0]}")/base-test.sh" | |||
There was a problem hiding this comment.
Required error checks are missing
The new test omits set -euo pipefail, which the testing guide requires at the start of every shell test. Add it before sourcing base-test.sh to enable the required checks for failed commands and unset variables. This repository requirement must be satisfied before merging.
| source "$(dirname "${BASH_SOURCE[0]}")/base-test.sh" | |
| set -euo pipefail | |
| source "$(dirname "${BASH_SOURCE[0]}")/base-test.sh" |
File Used: docs/testing.md (source)
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
|
Greptile's review comment on What was wrong: two places back up a file with What I pushed: Tested on a fresh Omarchy worker, with a symlinked
Second opinion: Codex Medium and muse-wonder (pi, thinking high) reviewed the change and found nothing to change. They agreed the regression is real in both places, that The scope and lint questions from my last comment still stand. This is |
The one conflict was bin/omarchy-font-set, where omacom#6958 now preserves foot's existing font size. Kept that and put --follow-symlinks on its sed -i, so a symlinked foot.ini stays linked as the rest of this branch intends. No other bare sed -i arrived with the merge.
|
The one conflict was in Tested on a fresh Omarchy worker, with a symlinked
Second opinion: Codex Medium reviewed the merge and found nothing to change. It confirmed the resolution keeps both #6958's behaviour and the flag. It also found no new bare The scope and lint questions from my earlier comments are unchanged. This is |
|
This no longer merges into The scope decision from the earlier review is still outstanding. A focused fix would preserve linked user configs in the runtime commands and keep the behavioural coverage already added to Codex High reviewed this round by reading the current diff, review comments, base-branch rules and the conflicting merge result. No code was pushed, and no worker tests or second code review ran this round because the scope decision stops further work. The earlier worker evidence was against |
|
Thank you @calebdw! Symlink preservation in |
…troArch commands (#20002) * Preserve symlinked user configs in text-size, glass, Sunshine, and RetroArch commands Extracted from #14343 and #7309 on top of #19969. Co-authored-by: Ali Yahya <[email protected]> Co-authored-by: Caleb White <[email protected]> * Write through symlinked shell.toml in omarchy-display-text-size Co-authored-by: Ali Yahya <[email protected]> Co-authored-by: Caleb White <[email protected]> --------- Co-authored-by: Ali Yahya <[email protected]> Co-authored-by: Caleb White <[email protected]>
…troArch commands (omacom#20002) * Preserve symlinked user configs in text-size, glass, Sunshine, and RetroArch commands Extracted from omacom#14343 and omacom#7309 on top of omacom#19969. Co-authored-by: Ali Yahya <[email protected]> Co-authored-by: Caleb White <[email protected]> * Write through symlinked shell.toml in omarchy-display-text-size Co-authored-by: Ali Yahya <[email protected]> Co-authored-by: Caleb White <[email protected]> --------- Co-authored-by: Ali Yahya <[email protected]> Co-authored-by: Caleb White <[email protected]>
Without --follow-symlinks, GNU sed writes a temp file and renames it over the target, replacing any symlink with a regular file. This silently breaks dotfile setups that symlink configs from a version-controlled repository (GNU Stow, chezmoi, yadm, etc.).
Every sed -i call across bin/ and migrations/ now includes --follow-symlinks. The flag is harmless on regular files and critical on symlinks, so there is no reason to omit it.
An architectural test (test/shell.d/sed-follow-symlinks-test.sh) enforces the rule in CI — any new bare sed -i in bin/ or migrations/ will fail the build. Agent instructions in AGENTS.md and agents/skills/migrations.md are updated with the guidance.
Thanks!