@@ -43,15 +43,11 @@ ${blue}Clean Utility:${white}
4343 run ${red} clean${white} ${yellow} :${white} removes debug folder, executables and temp files
4444
4545${blue} Miscellaneous:${white}
46- run [${red} --list-langs${white} /${red} -ll${white} ] ${yellow} :${white} lists all languages supported by current version of code-runner
47- run [${red} --version${white} /${red} -v${white} ] ${yellow} :${white} echoes the current version of code-runner"
48-
49- _ERROR_UFTC_ () {
50- echo " ${red} ERROR: ${white} This file type can't be compiled or the file does not exist!"
51- }
46+ run [${red} --list-langs${white} /${red} ll${white} ] ${yellow} :${white} lists all languages supported by current version of code-runner
47+ run [${red} --version${white} /${red} v${white} ] ${yellow} :${white} echoes the current version of code-runner"
5248
5349_EXIT_ () {
54- echo " ${blue} Exiting crunner... "
50+ echo " ${blue} Exiting code-runner "
5551 exit 0
5652}
5753
@@ -84,6 +80,8 @@ run() {
8480
8581 set -m
8682
83+ # C[++] fam specifics
84+ default_debugger
8785 CFLAGS=" -Wall"
8886 if [[ $DEBUG == true ]]; then
8987 CFLAGS+=" -g -O0"
@@ -92,7 +90,6 @@ run() {
9290 fi
9391
9492 if [[ ${FILE#* .} == c ]]; then
95- default_debugger
9693 " ${CC:= gcc} " ${CFLAGS} " $FILE " -o " ${FILE%% .* } .out"
9794 if [[ $DEBUG == true ]]; then
9895 " $debugger " " ${FILE%% .* } .out"
@@ -105,7 +102,6 @@ run() {
105102 fi
106103
107104 elif [[ ${FILE#* .} == cpp ]]; then
108- default_debugger
109105 " ${CXX:= g++} " ${CFLAGS} " $FILE " -o " ${FILE%% .* } .out"
110106 if [[ $DEBUG == true ]]; then
111107 " $debugger " " ${FILE%% .* } .out"
@@ -130,14 +126,12 @@ run() {
130126 dpyv=2
131127 fi
132128 rm -rf " ${FILE%% .* } .pyc" __pycache__
129+ elif [[ $pyv == 3 ]]; then
130+ py=" python3"
131+ dpyv=3
133132 else
134- if [[ $pyv == 3 ]]; then
135- py=" python3"
136- dpyv=3
137- else
138- py=" python2"
139- dpyv=2
140- fi
133+ py=" python2"
134+ dpyv=2
141135 fi
142136 echo " ${yellow} >> Using python $dpyv ${white} "
143137 if [[ $COMPILE == true ]]; then
@@ -159,7 +153,6 @@ run() {
159153 javac " $FILE "
160154 JCF=$( find . -type f -name " *.class" -mmin -1 | cut -c 3-)
161155 classFileCount=$( find . -type f -name " *.class" -mmin -1 | wc -l)
162-
163156 if [[ $COMPILE != true ]]; then
164157 while [ " $classFileCount " -gt 0 ]
165158 do
@@ -193,7 +186,7 @@ run() {
193186 go run " $FILE "
194187 fi
195188 if [[ $PERSISTENT != true ]]; then
196- rm " ${FILE%% .* } .out"
189+ rm -rf " ${FILE%% .* } .out"
197190 fi
198191
199192 elif [[ ${FILE#* .} == pl ]]; then
@@ -214,10 +207,6 @@ run() {
214207 else
215208 runghc " $FILE "
216209 fi
217-
218- else
219- _ERROR_UFTC_
220- _EXIT_
221210 fi
222211}
223212
@@ -231,8 +220,7 @@ for arg in "$@"; do
231220 " -h" | " --help" )
232221 echo " $USAGE " && exit 0
233222 ;;
234-
235- " ll" | " --list-langs" )
223+ " --list-langs" | " ll" )
236224 echo
237225 echo " ${cyan} Languages supported by the currently installed version of ${red} code-runner${cyan} :"
238226 echo " ${yellow} >>${white} C ${cyan} [${white} with ${green} debug${white} support${cyan} ]"
@@ -249,22 +237,8 @@ for arg in "$@"; do
249237 echo " ${yellow} >>${white} Haskell ${cyan} [${white} with ${green} debug${white} support${cyan} ]"
250238 echo
251239 ;;
252-
253- * " .c" | * " .cpp" | * " .py" | * " .rs" | * " .java" | * " .sh" | * " .js" | * " .go" | * " .pl" | * " .lua" | * " .rb" | * " .hs" )
254- FILE_LOCATION=$arg
255- if [[ ! -f $FILE_LOCATION ]]; then
256- _ERROR_UFTC_
257- _EXIT_
258- fi
259- if [[ $FILE_LOCATION != * /* ]]; then
260- FILE=$FILE_LOCATION
261- run
262- else
263- LOCATION=${FILE_LOCATION%/* }
264- FILE=${FILE_LOCATION##*/ }
265- cd " $LOCATION " || exit 1
266- run
267- fi
240+ " --version" | " v" )
241+ echo " ${cyan} code-runner ${white} version : ${yellow} 1.2.0${white} "
268242 ;;
269243
270244 " --cc=" * | " -c=" * )
@@ -318,11 +292,31 @@ for arg in "$@"; do
318292 " rcexe" )
319293 rclean_exe
320294 ;;
321- " --version" | " -v" )
322- echo " ${cyan} code-runner ${white} version : ${yellow} 1.2.0${white} "
295+
296+ * " .c" | * " .cpp" | * " .py" | * " .rs" | * " .java" | * " .sh" | * " .js" | * " .go" | * " .pl" | * " .lua" | * " .rb" | * " .hs" )
297+ FILE_LOCATION=$arg
298+ if [[ ! -f $FILE_LOCATION ]]; then
299+ echo " ${red} ERROR: ${white} Specified file doesn't exist."
300+ _EXIT_
301+ fi
302+ if [[ $FILE_LOCATION != * /* ]]; then
303+ FILE=$FILE_LOCATION
304+ run
305+ else
306+ LOCATION=${FILE_LOCATION%/* }
307+ FILE=${FILE_LOCATION##*/ }
308+ cd " $LOCATION " || exit 1
309+ run
310+ fi
311+ ;;
312+ * .* )
313+ echo " ${red} ERROR: ${white} Usupported file-type specified.
314+ To get a list of supported file-types use: ${green} run ll${white} "
315+ _EXIT_
323316 ;;
324317 * )
325- _ERROR_UFTC_
318+ echo " ${red} ERROR: ${white} Unknown argument specified.
319+ To get a list of supported arguments use: ${green} run --help${white} "
326320 _EXIT_
327321 ;;
328322 esac
0 commit comments