-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun
More file actions
35 lines (28 loc) · 1.43 KB
/
run
File metadata and controls
35 lines (28 loc) · 1.43 KB
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
#!bash
# clear; clear
# usage: ./run srcfile.cc
# e.g. 1: run A.cc
# e.g. 2: run 456a.cc
# Option 1 (original):
# Uncomment for usage as described above^^^
# g++ $1 -g -Og -std=c++11 -Wall -Wextra -Wconversion -Wshadow -Wfatal-errors -o sol || exit
# Option 2 (my way):
# usage, just call `run` (even if run is in a directory above yours i.e. `../run` from some deeper dir such as `A` with some
# src file A.cc in it, doesn't matter name, just that there is a *.cc file in the directory you run from AND IT IS THE ONLY
# SOURCE FILE WHERE YOU ARE!)
# myfile=`find -maxdepth 1 -type f -name "*.cc"`
# Option 3 (replace find with ls -t1 *.cc ...):
# same usage as in option 2, but matches the LAST UPDATED *.cc file and uses that (best way!!)
myfile=`ls -t1 *.cc | head -n 1`
echo $myfile
g++ $myfile -g -Og -std=c++17 -Wall -Wextra -Wconversion -Wshadow -o sol || exit
# Option 4:
# this way changes the usage so you don't have to type the .cc after the
# problem source file (e.g. for A.cc, just type ./run A)
# g++ $1.cc -g -Og -std=c++11 -Wall -Wextra -Wconversion -Wshadow -Wfatal-errors -o sol || exit
# expects input files of the form 1.in, something.in, 2.in, etc.
# expects output files to diff against of the form 1.out, or, 1.ans, etc. (first char after '.' is o or a, followed by 2 more characters)
for i in *.in; do
echo --- $i
./sol < $i > o && (diff -y o ${i::-3}.[ao]?? > t || cat t) || cat o
done