Skip to content
Snippets Groups Projects
find_module_paths 1.15 KiB
Newer Older
  • Learn to ignore specific revisions
  • Easy Build's avatar
    Easy Build committed
    find_module_paths()
    {
        echo -e "\n$1"
    
        local ML="$(ml show "$1" 2>&1)"
    
    Easy Build's avatar
    Easy Build committed
        if [ $? != 0 ]; then
    	echo "Error: Module not found"
    	return 1
        fi
    
        local MODROOT="$(echo "$ML" | grep "EBROOT" | cut -d ',' -f 2 | cut -d '"' -f 2)"
    
    Easy Build's avatar
    Easy Build committed
        if [ ! -d "$MODROOT" ]; then
    	echo "Error: Non-standard installation, exiting..."
            exit 1
        fi
    
        local MODFILE="$(echo "$ML" | head -n3 | grep "\/[^[:space:]]*:" | tr -d ': ')"
    
    Easy Build's avatar
    Easy Build committed
        echo "    ROOT: $MODROOT"
    
        if [ -L "$MODFILE" ]; then
    	local MODFILE2="$(readlink "$MODFILE")"
    
    Easy Build's avatar
    Easy Build committed
    	echo "    MODL: $MODFILE"
            echo "    MODF: $MODFILE2"
    
    	if [ "$(echo "$MODROOT" | rev | cut -d '/' -f 1)" != "$(echo "$MODFILE2" | sed 's/.lua//' | rev | cut -d '/' -f 1)" ] || [ "$(echo "$MODROOT" | rev | cut -d '/' -f 1)" != "$(echo "$MODFILE" | sed 's/.lua//' | rev | cut -d '/' -f 1)" ];then
    
    Easy Build's avatar
    Easy Build committed
    	    echo -e "\nError: Non-standard installation, exiting..."
    	    exit 1
    	fi
        else
            echo "    MODF: $MODFILE"
    
    	if  [ "$(echo "$MODROOT" | rev | cut -d '/' -f 1)" != "$(echo "$MODFILE" | sed 's/.lua//' | rev | cut -d '/' -f 1)" ];then
    
    Easy Build's avatar
    Easy Build committed
    	    echo -e "\nError: Non-standard installation, exiting..."
    	    exit 1
            fi
        fi
    }