Skip to content

Instantly share code, notes, and snippets.

@paulojeronimo
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulojeronimo/2f8010f81468d53edcb6 to your computer and use it in GitHub Desktop.
Save paulojeronimo/2f8010f81468d53edcb6 to your computer and use it in GitHub Desktop.

A very small bug fix at forge bash script

Yesterday I was doing some improvements on bash scripts that I wrote to assembly a Java EE development and execution environment. I use they on my own computer (a triple-boot MacBook Pro with OS X 10.10, Fedora 21, and Windows 8) and also on students and customer machines. Soon I will have a time to post some notes about those scripts on this blog. I execute they on Linux environments (Fedora, CentOS, Debian and Ubuntu) and, also, on OS X. I intend to make they runnable on Cygwin (although I don’t have any assumption about when I will do this).

I was doing fixes in those scripts to add an possibility to use it for an installation of tools in directories names containing spaces. After I did the fixes, I tried to execute the forge’s script. But this try made me unhappy, due to a bug:

$ lsb_release -id
Distributor ID: Fedora
Description:    Fedora release 21 (Twenty One)
$ pwd
/home/pj/thir with spaces/forge-distribution-2.14.0.Final
$ export JAVA_HOME=/usr/java/jdk1.8.0_31
$ export FORGE_HOME="$PWD"
$ export PATH="$FORGE_HOME/bin":$PATH
$ forge --version
Using Forge at /home/pj/thir with spaces/forge-distribution-2.14.0.Final
Forge version 2.14.0.Final
forge: unrecognized option: 'with'
Try 'forge --help' for more information.
forge: unrecognized option: 'spaces/forge-distribution-2.14.0.Final/addons/'
Try 'forge --help' for more information.

I made a fix for the script and wrote a patch for it. You can apply this patch on your own Forge installation by doing a "copy and paste" of the following commands in your opened shell (make sure you have the patch utility installed and also the FORGE_HOME variable configured):

cd "$FORGE_HOME/bin"
patch forge <<'EOF'
--- forge.original	2015-02-20 17:27:38.720110523 -0200
+++ forge	2015-02-20 17:42:37.830255342 -0200
@@ -160,7 +160,7 @@

 #
 if [ -r "$FORGE_HOME/addons/" ] ; then
-  ADDONS_DIR="--immutableAddonDir $FORGE_HOME/addons/"
+  ADDONS_DIR="--immutableAddonDir \"$FORGE_HOME/addons/\""
 fi

 forge_exec_cmd="\"$JAVACMD\" $FORGE_DEBUG_ARGS $FORGE_OPTS \"-Dforge.standalone=true\" \"-Dforge.home=${FORGE_HOME}\" \
EOF

After apply the patch, you can invoke the script again (with no errors this time):

$ forge --version
Using Forge at /home/pj/thir with spaces/forge-distribution-2.14.0.Final
Forge version 2.14.0.Final
$ forge
Using Forge at /home/pj/thir with spaces/forge-distribution-2.14.0.Final

    _____
   |  ___|__  _ __ __ _  ___
   | |_ / _ \| `__/ _` |/ _ \  \\
   |  _| (_) | | | (_| |  __/  //
   |_|  \___/|_|  \__, |\___|
                   |__/

JBoss Forge, version [ 2.14.0.Final ] - JBoss, by Red Hat, Inc. [ http://forge.jboss.org ]

[bin]$

This is a very small bug that only impacts users with Forge installed on a directory containing spaces at his name. Nothing more. Anyway, I created a pull request with my contribuition for this project.

Forge is very nice tool. I’m happy to have contributed in some way! =)

@lincolnthree
Copy link

Awesome! Thanks for this! Those nasty spaces always get in the way :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment