-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrunCs
More file actions
executable file
·36 lines (29 loc) · 875 Bytes
/
Copy pathrunCs
File metadata and controls
executable file
·36 lines (29 loc) · 875 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
## Description: Compiles and runs a cs file then deletes the class file
## Dependencies: csc, rm, mktemp, mono
## Usage: runCs <filename>
## Arguments: <filename> - the name of the cs file to compile and run
## Author: Tom Steer
# Check that the correct number of arguments have been passed
if [ $# -ne 1 ]; then
echo "Usage: runCs <filename>"
exit 1
fi
# Check that the file exists
if [ ! -f $1 ]; then
echo "File $1 does not exist"
exit 1
fi
# Check that the file is a cs file
if [[ $1 != *.cs ]]; then
echo "File $1 is not a C# file"
exit 1
fi
# Generate temp dir
dir=$(mktemp -d)
# Compile the file
csc -out:$dir/$(basename $1 .cs).exe $1 "/home/tom/Documents/BSc Cyber Security/WM240 - Cyber Context of Software Engineering/GlobalModules/GlobalModules.cs"
# Run the file
mono $dir/$(basename $1 .cs).exe
# Remove the temp dir
rm -rf $dir