Skip to content

Commit

Permalink
Do not escape $@ twice in validator run script generator.
Browse files Browse the repository at this point in the history
This is not needed because it is within single quotes.
  • Loading branch information
nickygerritsen committed Feb 29, 2024
1 parent b499362 commit 8463938
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions judge/judgedaemon.main.php
Original file line number Diff line number Diff line change
Expand Up @@ -418,13 +418,15 @@ function fetch_executable_internal(
// no main class detection here
$buildscript .= "echo 'COMPARE_DIR=\$(dirname \"\$0\")' >> run\n";
$mainClass = basename($unescapedSource, '.java');
$buildscript .= "echo 'java -cp \"\$COMPARE_DIR\" $mainClass \"\\\$@\"' >> run\n";
// Note: since the $@ is within single quotes, we do not need to double escape it.
$buildscript .= "echo 'java -cp \"\$COMPARE_DIR\" $mainClass \"\$@\"' >> run\n";
$buildscript .= "chmod +x run\n";
break;
case 'py':
$buildscript .= "echo '#!/bin/sh' > run\n";
$buildscript .= "echo 'COMPARE_DIR=\$(dirname \"\$0\")' >> run\n";
$buildscript .= "echo 'python3 \$COMPARE_DIR/$source' \"\\\$@\" >> run\n";
// Note: since the $@ is within single quotes, we do not need to double escape it.
$buildscript .= "echo 'python3 \"\$COMPARE_DIR/$source\" \"\$@\"' >> run\n";
$buildscript .= "chmod +x run\n";
break;
}
Expand Down

0 comments on commit 8463938

Please sign in to comment.