#  3/27/2014  DL
#
# $Id$
# $HeadURL$
#
# This is sourced by the "filter_path" alias. It
# uses the filter_path python script to do the
# heavy lifting. This is needed because the stupid
# design of the CLASSPATH variable used by java
# includes a wildcard ("*") which is very difficult
# to deal with in a shell that often wants to 
# replace it!
# 
# This script is the middle part of the triad of 
# utilities needed to make this work in an intuitive
# way for the user.
#
#  filter_path  ->  filter_path.csh   ->   filter_path
#    (alias)       (this csh script)     (Python script)
#
# 
# contact:
#  davidl@jlab.org   x5567
#

if ( $#argv < 1 ) then

	echo "At least one argument must be passed to filter_path!"
	
else

	# name of PATH environment variable
	set pathvar=$1
	
	# make initial part of command
	set cmd="${SETUP_SCRIPTS}/../filter_path $pathvar"

	# Add additional arguments. These need to be wrapped
	# in single quotes (') within the command so any
	# wildcards don't get replaced.
	set i=2
	while ( $i <= $#argv )
		set a="$argv[$i]"
		set cmd="$cmd '$a'"
		@ i++
	end
	
	# Run the filter_path Python script and use its
	# output to set the appropriate environment variable
	set tmp="`${cmd}`"
	setenv $pathvar "$tmp"
	
endif
