Run a command safely without shell interpretation and without redirecting stdin, stdout, or stderr Args: cmd: The command to run env: Extra environment variables to define in the subprocess. Defaults to None. Returns: subprocess returncode
(
cmd: str | Sequence[str], env: Mapping[str, str] | None = None
)
| 106 | |
| 107 | |
| 108 | def run_interactive( |
| 109 | cmd: str | Sequence[str], env: Mapping[str, str] | None = None |
| 110 | ) -> int: |
| 111 | """Run a command safely without shell interpretation and without redirecting stdin, stdout, or stderr |
| 112 | |
| 113 | Args: |
| 114 | cmd: The command to run |
| 115 | env: Extra environment variables to define in the subprocess. Defaults to None. |
| 116 | |
| 117 | Returns: |
| 118 | subprocess returncode |
| 119 | """ |
| 120 | if env is not None: |
| 121 | env = {**os.environ, **env} |
| 122 | if isinstance(cmd, str): |
| 123 | warnings.warn( |
| 124 | "Passing a string to cmd.run_interactive() is deprecated and will be removed in v5. " |
| 125 | "Use a list of arguments instead, or use cmd.run_interactive_shell() explicitly.", |
| 126 | DeprecationWarning, |
| 127 | stacklevel=2, |
| 128 | ) |
| 129 | return subprocess.run(cmd, shell=True, env=env).returncode |
| 130 | return subprocess.run(cmd, shell=False, env=env).returncode |
| 131 | |
| 132 | |
| 133 | def run_interactive_shell(cmd: str, env: Mapping[str, str] | None = None) -> int: |
nothing calls this directly
no outgoing calls
no test coverage detected