Newer
Older
#!/bin/bash
set -e
function print_usage {
echo "Usage: set-environment [ ENVIRONMENT_NAME | ENVIRONMENT_FILE ]"
}
function list_known_environments {
# TODO
return 0
}
function link_environment {
if [[ "$1" == /* ]]; then
TARGET="$1"
else
TARGET="../$1"
fi
echo "Linking main/environment.h to $TARGET"
ln -s "$TARGET" "main/environment.h"
touch --no-create "main/environment.h"
}
if [[ -z "$1" ]]; then
print_usage
list_known_environments
elif [[ -f "$1" && "$1" == *.h ]]; then
link_environment "$1"
elif [[ -f "environments/$1.h" ]]; then
link_environment "environments/$1.h"
else
echo "Cannot find environment config in the following locations:"
echo "$1"
echo "environments/$1.h"
fi