#!/bin/bash module_confirm () { local FILE local DIR local NAME DIR=$1 NAME=$2 # echo finding $NAME in $DIR FILE="$(find ${DIR} -type f -name "${NAME}.mod" -o -name "${NAME}".sh)" # echo files found $FILE COUNT=0 if [ "$FILE" ]; then COUNT=$(echo $FILE | xargs -n 1 | wc -l) fi # echo Number: $COUNT if [ $COUNT -gt 1 ]; then echo two or more modules of same name found, aborting echo $FILE | xargs -n 1 return 1 fi [ $COUNT == 1 ] && echo $FILE && return 0 return 1 } # if succesfull returns the path function module_find () { [ ! $1 ] && echo "no module specified" && return 1 local MDIRS local MDIR local DIRS local MODULE=$1 DIRS=( \ $([ $BASH_SHELL_USER ] && echo $HOME/$BASH_SHELL_USER || echo $HOME/bash/shell) \ $BASH_SHELL_HOST/$(hostname) $BASH_SHELL_HOST/all \ $BASH_SHELL_NETWORK/$NETWORKNAME \ $BASH_SHELL_NETWORK/all \ $BASH_SHELL_BASE \ ) # echo ${DIRS[@]} MDIRS=() j=0 cnt=${#DIRS[@]} for ((i=0;i