(tokens: list[str])
| 79 | |
| 80 | |
| 81 | def _unwrap_shell_wrapper(tokens: list[str]) -> tuple[dict[str, str], list[str]]: |
| 82 | current = _truncate_shell_chain(tokens) |
| 83 | env_vars, current = _extract_env_assignments(current) |
| 84 | if not current: |
| 85 | return env_vars, current |
| 86 | |
| 87 | first = Path(str(current[0]).strip("\"'")).name.lower() |
| 88 | if first == "cmd" and len(current) >= 3 and current[1].lower() == "/c": |
| 89 | nested_env, nested_tokens = _unwrap_shell_wrapper(current[2:]) |
| 90 | return {**env_vars, **nested_env}, nested_tokens |
| 91 | |
| 92 | if first in {"bash", "sh"} and len(current) >= 3 and current[1] in {"-c", "-lc"}: |
| 93 | nested_env, nested_tokens = _unwrap_shell_wrapper(_split_command(current[2])) |
| 94 | return {**env_vars, **nested_env}, nested_tokens |
| 95 | |
| 96 | if first in {"powershell", "powershell.exe", "pwsh", "pwsh.exe"} and len(current) >= 3: |
| 97 | if current[1].lower() in {"-command", "-c"}: |
| 98 | nested_env, nested_tokens = _unwrap_shell_wrapper(_split_command(current[2])) |
| 99 | return {**env_vars, **nested_env}, nested_tokens |
| 100 | |
| 101 | return env_vars, current |
| 102 | |
| 103 | |
| 104 | def normalize_target_spec(train_command: str, code_dir: Path) -> tuple[list[str], dict[str, str]]: |
no test coverage detected