cmd-action state
If action is a list of strings and instances of any Path class from pathlib, by default it will be executed without the shell (Popen argument shell=False).
However, if you trace through it, the call to Popen is still shell=True.
#!/usr/bin/env python3
import logging
import doit
from doit.action import CmdAction
DOIT_CONFIG = {
'verbosity': 2,
'default_tasks': ['check_results']
}
def task_check_results():
def check_results(echo_as_list_in_CmdAction, echo_as_list_in_CmdAction_shell_False):
failed = False
logging.warning('echo_as_list_in_CmdAction = "%s"', echo_as_list_in_CmdAction)
if echo_as_list_in_CmdAction != 'foo bar':
failed = True
logging.warning('echo_as_list_in_CmdAction_shell_False = "%s"', echo_as_list_in_CmdAction_shell_False)
if echo_as_list_in_CmdAction_shell_False != 'foo bar':
failed = True
return not failed
return {
'actions': [check_results],
'getargs': {
'echo_as_list_in_CmdAction': ('echo_as_list_in_CmdAction', 'stdout'),
'echo_as_list_in_CmdAction_shell_False': ('echo_as_list_in_CmdAction_shell_False', 'stdout'),
},
'uptodate': [False],
}
def task_echo_as_list_in_CmdAction():
return {
'actions': [CmdAction(['echo', '-n', 'foo bar'], save_out='stdout')],
}
def task_echo_as_list_in_CmdAction_shell_False():
return {
'actions': [CmdAction(['echo', '-n', 'foo bar'], save_out='stdout', shell=False)],
}
def task_echo_as_list():
return {
'actions': [['echo', '-n', 'foo bar']],
}
if __name__ == '__main__':
doit.run(globals())
Environment
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too