From c1337e49468cb03ce1f1373c1abee3c6411e94be Mon Sep 17 00:00:00 2001 From: Eric Knibbe Date: Mon, 1 Sep 2025 14:30:43 -0400 Subject: [PATCH] write_exec_script: add args parameter --- Library/Homebrew/extend/pathname.rb | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 40b6356d7f..aadfe18dca 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -273,19 +273,30 @@ class Pathname end # Writes an exec script in this folder for each target pathname. - sig { params(targets: T.any(T::Array[T.any(String, Pathname)], String, Pathname)).void } - def write_exec_script(*targets) + sig { + params(targets: T.any(T::Array[T.any(String, Pathname)], String, Pathname), + args: T.nilable(T.any(String, T::Array[String]))).void + } + def write_exec_script(*targets, args: nil) targets.flatten! if targets.empty? opoo "Tried to write exec scripts to #{self} for an empty list of targets" return end mkpath + + args = if args.is_a?(Array) + args.join(" ") + elsif args.is_a?(String) + args + end + arg_str = "#{args} " if args.present? + targets.each do |target| target = Pathname.new(target) # allow pathnames or strings join(target.basename).write <<~SH #!/bin/bash - exec "#{target}" "$@" + exec "#{target}" #{arg_str}"$@" SH end end