Skip to content

Commit 544ee29

Browse files
author
Michael Vasseur
committed
Handle Jaap his findings
1 parent 348ea2d commit 544ee29

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

judge/judgedaemon.main.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,21 @@ function dj_getopt(string $short_options, array $long_options = []): array
2929
echo "Error: parsing options failed.\nPlease check: `register_argc_arg` in php.ini.\n";
3030
usage();
3131
}
32-
$unknown = false;
32+
$unknown_option = false;
3333
foreach (array_slice($argv, 1) as $arg) {
34-
if (str_starts_with($arg, '-') && !array_key_exists(ltrim($arg, '-'), $options)) {
34+
if (str_starts_with($arg, '--') && !array_key_exists(ltrim($arg, '-'), $options)) {
3535
echo "Error: Unknown option: $arg\n";
36-
$unknown = true;
36+
$unknown_option = true;
37+
} elseif (str_starts_with($arg, '-') {
38+
foreach (ltrim($arg, '-') as $c) {
39+
if (!array_key_exists($c, $options)) {
40+
echo "Error: Unknown option: $arg\n";
41+
$unknown_option = true;
42+
}
43+
}
3744
}
3845
}
39-
if ($unknown) {
46+
if ($unknown_option) {
4047
usage();
4148
}
4249
return $options;

0 commit comments

Comments
 (0)