From 647107833d56e55bd8894bb57d549e1c4c36d09c Mon Sep 17 00:00:00 2001 From: piekstra Date: Wed, 23 Sep 2026 13:19:13 -0400 Subject: [PATCH] fix(homebrew-alias): keep staged paths absolute in install-step args base: resolves only a run step's command path, not its args, so the rewritten quarantine step ran xattr on a bare binary name in the wrong working directory and every cask upgrade failed and reverted. Rewrite #{staged_path} to the {{staged_path}} install-step template token instead, which Homebrew expands inside args. --- actions/homebrew-alias/modernize.sh | 7 ++++--- actions/homebrew-alias/test_modernize.sh | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/actions/homebrew-alias/modernize.sh b/actions/homebrew-alias/modernize.sh index 1ffcc3b..4cb5121 100644 --- a/actions/homebrew-alias/modernize.sh +++ b/actions/homebrew-alias/modernize.sh @@ -27,9 +27,10 @@ render() { /^[[:space:]]*system_command[[:space:]]+/ { sub(/system_command[[:space:]]+/, "run ") } - /"#\{staged_path\}\// { - sub(/"#\{staged_path\}\//, "\"") - sub(/\][[:space:]]*$/, "], base: :staged_path") + # base: resolves only the command path, never args, so a staged path in + # args has to stay absolute through the install-step template token. + /#\{staged_path\}/ { + gsub(/#\{staged_path\}/, "{{staged_path}}") } { print } ' "$file" diff --git a/actions/homebrew-alias/test_modernize.sh b/actions/homebrew-alias/test_modernize.sh index 8767f17..57f0ce4 100644 --- a/actions/homebrew-alias/test_modernize.sh +++ b/actions/homebrew-alias/test_modernize.sh @@ -31,8 +31,10 @@ for stanza in preflight_steps postflight_steps uninstall_preflight_steps uninsta done echo "$out" | grep -q '^ # postflight do must not change inside a comment$' \ && ok "comment preserved" || bad "comment preserved" -echo "$out" | grep -q 'run "/usr/bin/xattr", args: \["-dr", "com.apple.quarantine", "example"\], base: :staged_path' \ +echo "$out" | grep -qF 'run "/usr/bin/xattr", args: ["-dr", "com.apple.quarantine", "{{staged_path}}/example"]' \ && ok "command converted to install-step DSL" || bad "command converted to install-step DSL" +echo "$out" | grep -q 'base: :staged_path' \ + && bad "staged path must not move to base:" || ok "staged path kept in args" echo "$out" | grep -q 'system_command' \ && bad "legacy command should be absent" || ok "legacy command absent"