Skip to content

situate shell paths pattern

Tim L edited this page Mar 24, 2014 · 11 revisions

When installing shell-based tools, it can often be a pain to deal with getting the right paths and classpaths set for the tool to work properly. I've started using what I call the "situate path pattern" that is a script that you can call from anywhere that returns the path string to concatenate to your existing paths. If none are needed, then an empty string is returned (so , it's idempotent; feel free to do it as often as you need and your path won't get cluttered).

Scripts that apply the situate shell pattern (listed from oldest to newest):

PATH:

CLASSPATH:

Example usage:

bash-3.2$ /Users/me/projects/plunk/bin/pl-situate-classpath.sh  --help
pl-situate-classpath.sh [--help] [-v] [--export]

Put them there by executing:

    export CLASSPATH=$CLASSPATH`/Users/me/projects/plunk/bin/pl-situate-classpath.sh`

bash-3.2$ /Users/me/projects/plunk/bin/pl-situate-classpath.sh
:/Users/me/projects/plunk/lib/csv2rdf4lod/openrdf-sesame-2.2.4-onejar.jar:/Users/me/projects/plunk/lib/csv2rdf4lod/slf4j-api-1.5.6.jar:/Users/me/projects/plunk/lib/csv2rdf4lod/slf4j-nop-1.5.6.jar:/Users/me/projects/plunk/lib/csv2rdf4lod.jar

bash-3.2$ export CLASSPATH=$CLASSPATH`/Users/me/projects/plunk/bin/pl-situate-classpath.sh`
<nothing returned; the CLASSPATH was updated>

bash-3.2$ /Users/me/projects/plunk/bin/pl-situate-classpath.sh
<nothing returned, since no new paths need to be added>

What is next

Clone this wiki locally