From 1a7ae77b72df1d271c5760d7644d79167a4dffb6 Mon Sep 17 00:00:00 2001
From: Brandon Rodriguez <brodriguez8774@gmail.com>
Date: Fri, 28 Feb 2020 14:26:01 -0500
Subject: [PATCH] Create initial run.sh bash script

---
 documents/references.md | 20 ++++++++---
 run.sh                  | 77 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 93 insertions(+), 4 deletions(-)
 create mode 100755 run.sh

diff --git a/documents/references.md b/documents/references.md
index 0b685f8..88477c4 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 0000000..c1ebe80
--- /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 $@
-- 
GitLab