mirror of
https://github.com/ansible-collections/ansible.posix.git
synced 2026-02-04 08:01:49 +00:00
Allow unsetting env vars (#7)
This commit is contained in:
parent
5b17c47723
commit
7e70deb734
2 changed files with 14 additions and 2 deletions
|
|
@ -38,7 +38,13 @@ class ShellModule(ShModule):
|
|||
def env_prefix(self, **kwargs):
|
||||
env = self.env.copy()
|
||||
env.update(kwargs)
|
||||
return ' '.join(['set -lx %s %s;' % (k, shlex_quote(text_type(v))) for k, v in env.items()])
|
||||
ret = []
|
||||
for k, v in kwargs.items():
|
||||
if v is None:
|
||||
ret.append('set -e %s;' % k)
|
||||
else:
|
||||
ret.append('set -lx %s %s;' % (k, shlex_quote(text_type(v))))
|
||||
return ' '.join(ret)
|
||||
|
||||
def build_module_command(self, env_string, shebang, cmd, arg_path=None):
|
||||
# don't quote the cmd if it's an empty string, because this will break pipelining mode
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue