craft_providers.util.env_cmd module

Helper(s) for env command.

craft_providers.util.env_cmd.formulate_command(env=None, *, chdir=None, ignore_environment=False)[source]

Create an env command with the specified environment.

For each key-value, the env command will include the key=value argument to the env command.

If a variable is None, then the env -u parameter will be used to unset it.

An empty environment will simply yield the env command.

NOTE: not all versions of env support –chdir, it is up to the caller to ensure compatibility.

Parameters
  • env (Optional[Dict[str, Optional[str]]]) – Environment flags to set/unset.

  • chdir (Optional[Path]) – Optional directory to run in.

  • ignore_environment (bool) – Start with an empty environment.

Return type

List[str]

Returns

List of env command strings.