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"