#!/bin/sh
# $Id: libpath,v 1.2 1995/02/23 12:53:57 tom Exp $
#
# Title:	libpath
# Author:	T.E.Dickey
# Created:	25 May 1994
#
# Function:	Displays information about the user's LD_LIBRARY_PATH
#		environment variable (which controls linking and loading of
#		dynamic libraries.
#
#		If no arguments given, this script displays the names of the
#		directories in the library-path.  If argument is given, it is
#		assumed to be a library name (e.g., "c" for -lc).  All matching
#		names are displayed; the first is the one that will be loaded.
#
#		Options (arguments beginning with "-") are passed to 'ls'.
#		
opts=""
name=""
for N in $*
do
	case $N in
	-*)
		opts="$opts $N"
		;;
	*)
		name=$N
		for P in `echo $LD_LIBRARY_PATH | sed -e 's/:/ /g'`
		do
			if [ "`echo $P/lib$N.s[oa].*`" != $P/lib$N.'s[oa].*' ]
			then
				ls $opts $P/lib$N.s[oa].*
			fi
			if [ -f $P/lib$N.a ]
			then
				ls $opts $P/lib$N.a
			fi
		done
	esac
done
#
if [ -z "$name" ]
then
	for P in `echo $LD_LIBRARY_PATH | sed -e 's/:/ /g'`
	do
		ls -d$opts $P
	done
fi
