diff --git a/documents/references.md b/documents/references.md index 0b685f8937dcb400825ab8593891ff23e5a81818..88477c44228c8d2476ee234c0717a363ea46449c 100644 --- a/documents/references.md +++ b/documents/references.md @@ -1,16 +1,28 @@ # Documents > References - -## Description All references to external logic. Includes anything from stack overflow links to notes about logic from previous works. -## References +## C ### All Printf Format Types <https://www.tutorialspoint.com/c_standard_library/c_function_printf.htm> -### Makefile +## Makefile * Purpose of ".PHONY" - <https://stackoverflow.com/a/2145605> * Have one command execute another - <https://stackoverflow.com/a/48552668> * Surpress output messages - <https://stackoverflow.com/a/3148530> + +## Bash + +### Getting Last Argument +<https://www.cyberciti.biz/faq/linux-unix-bsd-apple-osx-bash-get-last-argument/> + +### Color Output +https://stackoverflow.com/a/5947802 + +### Getting Script Directory +https://stackoverflow.com/a/337006 + +### Manipulating Strings +https://stackoverflow.com/a/14703709 diff --git a/run.sh b/run.sh new file mode 100755 index 0000000000000000000000000000000000000000..c1ebe80dd988bd16c03539150c8a2ef37d329073 --- /dev/null +++ b/run.sh @@ -0,0 +1,77 @@ +#!/usr/bin/env bash +### + # Script to compile and run iloc Value Numbering project. + ## + + +# Abort on error +set -e + + +# Global Variables. +return_value="" +color_reset='\033[0m' +color_red='\033[1;31m' +color_green='\033[1;32m' +color_blue='\033[1;34m' +color_cyan='\033[1;36m' + + +# Change location to script's directory. +# Makes logic consistent, regardless of what directory script is ran from. +cd "$(dirname "$0")" +cd ../ + + +function main () { + # Check if first arg was provided. + if [[ $1 != "" ]] + then + execute_single_file $@ + else + execute_all_files $@ + fi + + echo "" + echo "Terminating script." +} + + + +### + # Runs a single cache simulation file. + ## +function execute_single_file () { + # Get passed filename. + echo $@ + for i in $@; do :; done + echo $i + exit 0 +} + + +### + # Runs all cache simulation files. + ## +function execute_all_files () { + echo -e "${color_red}Not yet implemented.${color_reset}" + exit 1 +} + + +### + # Gets absolute path of provided file/directory. + ## +function get_absolute_path () { + # First check if valid file or directory. + if [[ -d $1 || -f $1 ]] + then + return_value="$(cd "$(dirname "$1")" && pwd)/$(basename "$1")" + else + echo -e "${color_red}Passed value ($1) does not appear to be a file or directory.${color_reset}" + return_value="" + fi +} + + +main $@