Skip to content

Commit 9d954ba

Browse files
authored
Fix emrun arg handling (#21884)
Fixes: #21883
1 parent b94001f commit 9d954ba

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

emrun.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,15 +1568,14 @@ def parse_args(args):
15681568
parser.add_argument('cmdlineparams', nargs='*')
15691569

15701570
# Support legacy argument names with `_` in them (but don't
1571-
# advertize these in the --help message.
1572-
newargs = []
1573-
for a in args:
1571+
# advertize these in the --help message).
1572+
for i, a in enumerate(args):
1573+
if a == '--':
1574+
break
15741575
if a.startswith('--') and '_' in a:
1575-
newargs.append(a.replace('_', '-'))
1576-
else:
1577-
newargs.append(a)
1576+
args[i] = a.replace('_', '-')
15781577

1579-
return parser.parse_args(newargs)
1578+
return parser.parse_args(args)
15801579

15811580

15821581
def run(args):

test/test_browser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5594,7 +5594,7 @@ def test_emrun(self):
55945594
args_base + ['--private_browsing', '--port', '6941'],
55955595
args_base + ['--dump_out_directory', 'other dir/multiple', '--port', '6942']
55965596
]:
5597-
args += [self.in_dir('hello_world.html'), '--', '1', '2', '--3', 'escaped space']
5597+
args += [self.in_dir('hello_world.html'), '--', '1', '2', '--3', 'escaped space', 'with_underscore']
55985598
print(shared.shlex_join(args))
55995599
proc = self.run_process(args, check=False)
56005600
self.assertEqual(proc.returncode, 100)
@@ -5607,6 +5607,7 @@ def test_emrun(self):
56075607
self.assertContained('argc: 5', stdout)
56085608
self.assertContained('argv[3]: --3', stdout)
56095609
self.assertContained('argv[4]: escaped space', stdout)
5610+
self.assertContained('argv[5]: with_underscore', stdout)
56105611
self.assertContained('hello, world!', stdout)
56115612
self.assertContained('Testing ASCII characters: !"$%&\'()*+,-./:;<=>?@[\\]^_`{|}~', stdout)
56125613
self.assertContained('Testing char sequences: %20%21 &auml;', stdout)

0 commit comments

Comments
 (0)