Skip to content

Commit

Permalink
Merge pull request #90 from cbeer/env
Browse files Browse the repository at this point in the history
fits scripts should resolve symlinks before loading relative paths
  • Loading branch information
daveneiman authored Aug 31, 2016
2 parents d7e09f5 + 0aebb13 commit 0120d1d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
18 changes: 16 additions & 2 deletions fits-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,22 @@
# Sets up the environment for launching a FITS instance via
# either the fits.sh launcher, or the fits-ngserver.sh Nailgun server

#FITS_HOME=`dirname "$0"`
FITS_HOME=`echo "$0" | sed 's,/[^/]*$,,'`
FITS_ENV_SCRIPT="$0"

# Resolve symlinks to this script
while [ -h "$FITS_ENV_SCRIPT" ] ; do
ls=`ls -ld "$FITS_ENV_SCRIPT"`
# Drop everything prior to ->
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
FITS_ENV_SCRIPT="$link"
else
FITS_ENV_SCRIPT=`dirname "$FITS_ENV_SCRIPT"`/"$link"
fi
done

FITS_HOME=`dirname $FITS_ENV_SCRIPT`

export FITS_HOME

# Uncomment the following line if you want "file utility" to dereference and follow symlinks.
Expand Down
18 changes: 16 additions & 2 deletions fits.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
#!/bin/bash
#!/usr/bin/env bash

. "$(dirname $BASH_SOURCE)/fits-env.sh"
FITS_SCRIPT="$0"

# Resolve symlinks to this script
while [ -h "$FITS_SCRIPT" ] ; do
ls=`ls -ld "$FITS_SCRIPT"`
# Drop everything prior to ->
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
FITS_SCRIPT="$link"
else
FITS_SCRIPT=`dirname "$FITS_SCRIPT"`/"$link"
fi
done

. "$(dirname $FITS_SCRIPT)/fits-env.sh"

cmd="java -classpath \"$APPCLASSPATH\" edu.harvard.hul.ois.fits.Fits $args"

Expand Down

0 comments on commit 0120d1d

Please sign in to comment.