Skip to content

Commit 0fba174

Browse files
committed
Call exe_arg() from run() not from filter_bytes
1 parent 41c086e commit 0fba174

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

nancy/__init__.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -368,19 +368,19 @@ def exe_arg(exe_arg: bytes):
368368

369369
def filter_bytes(
370370
input: Optional[bytes],
371-
external_command: list[bytes],
371+
exe_path: Path,
372+
exe_args: list[bytes]
372373
) -> bytes:
373-
"""Run `external_command` passing `input` on stdin.
374+
"""Run an external command passing `input` on stdin.
374375
375376
Args:
376377
input (Optional[bytes]): passed to `stdin`
377-
external_command (list[bytes]): command and arguments
378+
exe_path (Path): filesystem `Path` of the command to run
379+
exe_args (list[bytes]): arguments to the command
378380
379381
Returns:
380382
bytes: stdout of the command
381383
"""
382-
exe_path = exe_arg(external_command[0])
383-
exe_args = external_command[1:]
384384
debug(f"Running {exe_path} {b' '.join(exe_args)}")
385385
try:
386386
res = subprocess.run(
@@ -450,11 +450,13 @@ def run(args: Optional[list[bytes]], input: Optional[bytes]) -> bytes:
450450
if args is None:
451451
raise ValueError("$run needs at least one argument")
452452
debug(command_to_str(b"run", args, input))
453+
exe_path = exe_arg(args[0])
454+
exe_args = args[1:]
453455

454456
expanded_input = None
455457
if input is not None:
456458
expanded_input = self.inner_expand(input, expand_stack)
457-
return filter_bytes(expanded_input, args)
459+
return filter_bytes(expanded_input, exe_path, exe_args)
458460

459461
macros[b"run"] = run
460462

0 commit comments

Comments
 (0)