Skip to content

Instantly share code, notes, and snippets.

@JohnArchieMckown
Created October 16, 2014 12:30
Show Gist options
  • Save JohnArchieMckown/6594447ce93b71802ac9 to your computer and use it in GitHub Desktop.
Save JohnArchieMckown/6594447ce93b71802ac9 to your computer and use it in GitHub Desktop.
classmunge is a shell function to add a directory to the CLASSPATH used by Java. It will add the specified directory only if: (1) it currently exists and (2) it is not already on the PATH. It can add the directory either at the beginning of the CLASSPATH (defautl) or at the end of the CLASSPATH.
classmunge () {
if [ -e $1 ]; then
if ! echo $CLASSPATH | /bin/egrep -q "(^|:)$1($|:)" ; then
if [ "$2" = "after" ] ; then
CLASSPATH=$CLASSPATH:$1
else
CLASSPATH=$1:$CLASSPATH
fi
fi
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment