From da9cfe53f6c427d5cb918ae9dd03d98f7c21afa1 Mon Sep 17 00:00:00 2001 From: maheshgudi Date: Tue, 17 Oct 2017 12:43:03 +0530 Subject: Add shebang to bash code evaluator --- yaksh/bash_code_evaluator.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'yaksh/bash_code_evaluator.py') diff --git a/yaksh/bash_code_evaluator.py b/yaksh/bash_code_evaluator.py index a4f1389..038d39c 100644 --- a/yaksh/bash_code_evaluator.py +++ b/yaksh/bash_code_evaluator.py @@ -77,7 +77,8 @@ class BashCodeEvaluator(BaseEvaluator): if self.test_case_args: self.tc_args_path = self.create_submit_code_file('main.args') self.write_to_submit_code_file(self.tc_args_path, self.test_case_args) - self.user_answer = self.user_answer.replace("\r", "") + shebang = "#!/bin/bash\n" + self.user_answer = shebang + self.user_answer.replace("\r", "") self.test_case = self.test_case.replace("\r", "") self.write_to_submit_code_file(self.submit_code_path, self.user_answer) self.write_to_submit_code_file(self.test_code_path, self.test_case) -- cgit From aba4c79491fe6675948d584e572238eecf4fb82b Mon Sep 17 00:00:00 2001 From: mahesh Date: Fri, 20 Oct 2017 12:17:52 +0530 Subject: Add bash command instead of shebang --- yaksh/bash_code_evaluator.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'yaksh/bash_code_evaluator.py') diff --git a/yaksh/bash_code_evaluator.py b/yaksh/bash_code_evaluator.py index 038d39c..4a15af3 100644 --- a/yaksh/bash_code_evaluator.py +++ b/yaksh/bash_code_evaluator.py @@ -77,8 +77,7 @@ class BashCodeEvaluator(BaseEvaluator): if self.test_case_args: self.tc_args_path = self.create_submit_code_file('main.args') self.write_to_submit_code_file(self.tc_args_path, self.test_case_args) - shebang = "#!/bin/bash\n" - self.user_answer = shebang + self.user_answer.replace("\r", "") + self.user_answer = self.user_answer.replace("\r", "") self.test_case = self.test_case.replace("\r", "") self.write_to_submit_code_file(self.submit_code_path, self.user_answer) self.write_to_submit_code_file(self.test_code_path, self.test_case) @@ -100,13 +99,13 @@ class BashCodeEvaluator(BaseEvaluator): return False, msg, 0.0 if not clean_test_case_path: - ret = self._run_command(clean_ref_code_path, + ret = self._run_command(["bash", clean_ref_code_path], stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) proc, inst_stdout, inst_stderr = ret - ret = self._run_command(self.submit_code_path, + ret = self._run_command(["bash", self.submit_code_path], stdin=None, stdout=subprocess.PIPE, stderr=subprocess.PIPE @@ -137,7 +136,7 @@ class BashCodeEvaluator(BaseEvaluator): for tc in test_cases: loop_count += 1 if valid_answer: - args = [clean_ref_code_path] + \ + args = ["bash", clean_ref_code_path] + \ [x for x in tc.split()] ret = self._run_command(args, stdin=None, @@ -147,7 +146,7 @@ class BashCodeEvaluator(BaseEvaluator): proc, inst_stdout, inst_stderr = ret if self.file_paths: self.files = copy_files(self.file_paths) - args = [self.submit_code_path] + \ + args = ["bash", self.submit_code_path] + \ [x for x in tc.split()] ret = self._run_command(args, stdin=None, -- cgit