#!/bin/bash #************************************************************************ # E.S.O. - ALMA project # # "@(#) $Id: searchFile,v 1.2 2010/09/20 14:25:08 mzampare Exp $" # # who when what # -------- ---------- ------------------------------------------------- # mpasquat 2004-JUL-19 created #******************************************************************************* # ALMA - Atacama Large Millimeter Array # Copyright (c) ESO - European Southern Observatory, 2014 # (in the framework of the ALMA collaboration). # All rights reserved. # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA #******************************************************************************* #************************************************************************ # NAME # searchFile - search a file in the sequence INTROOT -> INTLIST -> ACSROOT # # SYNOPSIS # searchFile # # DESCRIPTION # Script that returns the variable value (INTROOT, INTLIST, ACSROOT) where the # specified file is found or the string "#error#" if not. # # FILES # # ENVIRONMENT # # RETURN VALUES # #error# - no argument provided or file not found # # CAUTIONS # # EXAMPLES # # SEE ALSO # # BUGS # #------------------------------------------------------------------------ file=$1 if [ "X$1" == "X" ] then echo "#error#" exit 0 fi if [ "X$INTROOT" != "X" ] then if [ -f $INTROOT/$file ] then echo $INTROOT exit 0 fi fi if [ "X$INTLIST" != "X" ] then INTLIST_LIST=`echo $INTLIST | sed s/\:/\ /g` for dir in $INTLIST_LIST do if [ -f $dir/$file ] then echo $dir exit 0 fi done fi if [ "X$ACSROOT" != "X" ] then if [ -f $ACSROOT/$file ] then echo $ACSROOT exit 0 else echo "#error#" fi else echo "#error#" fi