Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- readonly GITHUB_PATH=~/Documents/GitHub
- function compileRun () {
- r () {
- if [ $1 -eq 0 ]
- then #compiled successfully
- java $2
- return 0
- else #compile failed
- echo "Couldn't compile, so we will not run \"java $2\"" >&2
- return 1
- fi
- }
- if test -f "${1}.java"; then #this means that it finds the file you're trying to compile in the present directory
- javac "${1}.java"
- r $? $1
- return $?
- else #couldn't find your file, so it needs to search
- a=$(find ${GITHUB_PATH} -name ${1}.java)
- b=$(echo $a | sed -e 's/[^\/]*$//g')
- cd "$b"
- javac "$a"
- r $? $1
- return $?
- fi
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement