#! /bin/bash # This script is a trampoline to detect shells and versions # ...but only Bash 3+ is supported at the moment. # First, make sure this script is being sourced match $0 { with */CmdlineGL.lib echo "Usage: source /path/to/CmdlineGL.lib" exit 1 } # Then figure out where the lib path is setglobal CmdlineGL_SharePath = '"@share_path@'" # set by "make install" if test ! -d "@share_path@" { # Running from project dir, before "make install" setglobal CmdlineGL_SharePath = $(BASH_SOURCE%/*) } if test ! -d "$CmdlineGL_SharePath/lib-bash" { echo "Can't determine CmdlineGL share path (checked for '$CmdlineGL_SharePath/lib-bash')" return 1 } # Force safe defaults for paths. Caller can modify these afterward. setglobal CmdlineGL_TexPath = ""$CmdlineGL_SharePath/textures"" setglobal CmdlineGL_FontPath = ""$CmdlineGL_SharePath/fonts"" # Then load the lib appropriate for this shell. Right now bash is the only supported shell. if test -n $BASH_VERSION { setglobal CmdlineGL_LibPath = ""$CmdlineGL_SharePath/lib-bash"" source "$CmdlineGL_SharePath/lib-bash/CmdlineGL.lib" } else { echo "You must source this libary from bash." echo "No other shells are currently supported." return 1; }