Permalink
Browse files

Update xmlsh to `1.2.0` (and formula tweaks)

Formula now deletes Win32 and cygwin files during installation.
  • Loading branch information...
1 parent 9f42c6b commit 369229d6c02476690f317fda5e1236e4911cf6b2 Zearin committed Jul 10, 2012
Showing with 58 additions and 0 deletions.
  1. +58 −0 Library/Formula/xmlsh.rb
View
@@ -0,0 +1,58 @@
+require 'formula'
+
+
+class Xmlsh < Formula
+ homepage 'http://www.xmlsh.org'
+ url 'http://downloads.sourceforge.net/project/xmlsh/xmlsh/1.2.0/xmlsh_1_2_0.zip'
+ sha1 '999cff2dd41778924f26ea558d6a684c6988173d'
+ version '1.2.0'
+
+ def shim_script target
+ <<-EOS.undent
+ #!/usr/bin/env bash
+
+ # Use XDG_CONFIG_HOME if it exists
+ XDG_CONFIG_HOME=$XDG_CONFIG_HOME || $HOME || ( echo "ERROR IN STARTUP SCRIPT!"; exit 1 )
@adamv

adamv Jul 11, 2012

We generally don't reference XDG paths

@jacknagel

jacknagel Jul 11, 2012

Also, for completeness, there are a few things wrong with this line, if I'm reading your intentions correctly.

The construct "variable = val || other_val" doesn't exist in that form in shell script.

What you want is probably something along the lines of

: ${XDG_CONFIG_HOME:=$HOME}
test -n "$XDG_CONFIG_HOME" || exit 1

note that anything in parens is executed in a subshell, so exiting in that subshell will not exit the parent script early. You can see this with this simple example:

#!/bin/sh
(exit 1)
echo "foo"
+ #{self.libexec}/unix/xmlsh -rcfile ${XDG_CONFIG_HOME}/.xmlshrc
@adamv

adamv Jul 11, 2012

Don't need self before libexec

+
@adamv

adamv Jul 11, 2012

blank line in script file

+ EOS
+ end
+
+
+ # @TODO
@adamv

adamv Jul 11, 2012

Fix or remove TODO

+ # Look at maven.rb formula for example of installing
+ # things like README, LICENSE, etc. to the #{prefix}
+ # directory.
+
+
+ def install
+ libexec.install Dir["*"]
+
+ # the provided executable is, by default...uh, not executable.
+ system "chmod", "a+x", "#{self.libexec}/unix/xmlsh"
+
+ # remove windows files
+ system "rm", "-rf", "#{self.libexec}/win32", "#{self.libexec}/cygwin"
+
+ # Write mini-script to run as executable instead of `jar blah blah...`
+ (bin + 'xmlsh').write shim_script('xmlsh')
+ end
+
+
+ def caveats; <<-EOS.undent
+ This package uses the Java JLine library <jline.sourceforge.net>
+ for command line editing. It is known to be buggy on some (possible most)
+ OS X systems.
+
+ In spite of this, 'xmlsh' is still a powerful tool for working XML. Using
+ '*.xsh' scripts is also a workaround (somewhat...) to dealing with the
+ command line editing bugs.
+ EOS
+ end
+
+
+ def test
+ system "xmlsh", "#{self.libexec}/test/run_tests.xsh"
@adamv

adamv Jul 11, 2012

Need to be "#{bin}/xmlsh"

+ end
+
+end

0 comments on commit 369229d

Please sign in to comment.