diff options
| author | Adam Vandenberg | 2012-08-07 11:16:45 -0700 | 
|---|---|---|
| committer | Adam Vandenberg | 2012-10-27 19:28:42 -0700 | 
| commit | b40e5323ca055bf890406b634c97fccef49d9c68 (patch) | |
| tree | 327296a46501a9820e1a857c4a9ce58e66237762 | |
| parent | affe26f0c71e73926af00cb91d3c430151f554d3 (diff) | |
| download | homebrew-b40e5323ca055bf890406b634c97fccef49d9c68.tar.bz2 | |
Pathname: add exec and jar helpers
Closes #13318.
| -rw-r--r-- | Library/Homebrew/extend/pathname.rb | 24 | 
1 files changed, 24 insertions, 0 deletions
| diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 054e5b078..bfbb448cf 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 | 
