diff --git a/cpp.sh b/cpp.sh index c5387ab..b201965 100644 --- a/cpp.sh +++ b/cpp.sh @@ -15,23 +15,17 @@ if [ "$FILE_EXTENSION" == "c" ]; then clang -o output_program "$CODE_FILE" 2> compile_error.txt elif [ "$FILE_EXTENSION" == "cpp" ]; then clang++ -o output_program "$CODE_FILE" 2> compile_error.txt +else + echo "Invalid language specified! Use 'c' or 'cpp'." + exit 1 fi + # Check if there were any compilation errors if [ $? -ne 0 ]; then echo -e "Compilation failed!\n" cat compile_error.txt exit 1 fi -# Run the compiled program and capture runtime errors -./output_program > output.txt 2> runtime_error.txt - -# Check if there were any runtime errors -if [ $? -ne 0 ]; then - echo -e "Runtime error!\n" - cat runtime_error.txt - exit 1 - -fi # start if [ -f "/usr/src/app/cpp-engine/app/input.txt" ]; then # Run the compiled program with input redirection @@ -42,6 +36,7 @@ else fi # end if [ $? -ne 0 ]; then + echo -e "Runtime error occurred!\n" cat runtime_error.txt exit 1 fi diff --git a/js.sh b/js.sh index 0da7646..c0cf15d 100644 --- a/js.sh +++ b/js.sh @@ -1,30 +1 @@ -#!/bin/bash - -# Path to the Python file to run -INPUT_REQUIRED=false - -# Check for the flag (modify if using a different flag name) -if [[ "$1" == "inputtrue" ]]; then - INPUT_REQUIRED=true - shift # Remove the flag from the argument list -fi - - -CODE_FILE="/usr/src/app/js-engine/app/index.js" - - -if [[ $INPUT_REQUIRED == true ]]; then - - nodejs $CODE_FILE < /usr/src/app/js-engine/app/input.txt > output.txt 2> runtime_error.txt - -else - nodejs $CODE_FILE > output.txt 2> runtime_error.txt -fi - -if [ $? -ne 0 ]; then - echo "Runtime error!" - cat runtime_error.txt - exit 1 -fi - -cat output.txt +No code provided \ No newline at end of file