lib.ExecContext.run(), .sudo(): Rename env

The name of the env parameter to ExecContext.run() and .sudo() is not descriptive enough for which environment is supposed to be modified and how, so rename and split it up as follows:

- .run(): env -> mod_env

- .sudo(): env -> mod_env_sudo and mod_env_cmd

The parameters have the following meaning:

- "mod_env*" means that the environment is modified, not replaced

- "mod_env" and "mod_env_cmd" modify the environment "cmd" runs in

- "mod_env_sudo" modifies the environment sudo runs in

Fix the fallout of the API change all over jw-pkg.

Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
Jan Lindemann 2026-04-19 14:04:35 +02:00
commit 54aecff8e4
9 changed files with 164 additions and 159 deletions

View file

@ -17,7 +17,7 @@ class Exec(Base):
self.__askpass_orig: dict[str, str|None] = dict()
super().__init__(
uri = uri,
caps = self.Caps.Env,
caps = self.Caps.ModEnv,
**kwargs
)
@ -49,7 +49,7 @@ class Exec(Base):
wd: str|None,
verbose: bool,
cmd_input: bytes|None,
env: dict[str, str]|None,
mod_env: dict[str, str]|None,
interactive: bool,
log_prefix: str
) -> Result:
@ -57,8 +57,8 @@ class Exec(Base):
if cmd_input is None:
cmd_input = InputMode.Interactive if interactive else InputMode.NonInteractive
opts: dict[str, str] = []
if env:
for key, val in env.items():
if mod_env:
for key, val in mod_env.items():
opts.extend(['-o', f'SetEnv {key}="{val}"'])
if self.username:
opts.extend(['-l', self.username])