diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 054e5b078c..bfbb448cf1 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -348,6 +348,30 @@ class Pathname end end end + + # Writes an exec script in this folder for each target pathname + def write_exec_script *targets + targets = [targets].flatten + if targets.empty? + opoo "tried to write exec sripts to #{self} for an empty list of targets" + end + targets.each do |target| + target = Pathname.new(target) # allow pathnames or strings + (self+target.basename()).write <<-EOS.undent + #!/bin/bash + exec "#{target}" "$@" + EOS + end + end + + # Writes an exec script that invokes a java jar + def write_jar_script target_jar, script_name, java_opts="" + (self+script_name).write <<-EOS.undent + #!/bin/bash + exec java #{java_opts} -jar #{target_jar} "$@" + EOS + end + end # sets $n and $d so you can observe creation of stuff