-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cmd module integration tests for windows and fix space in path issue #48866
Conversation
@@ -166,7 +166,7 @@ def get_sam_name(username): | |||
return '\\'.join([domain, username]) | |||
|
|||
|
|||
def escape_argument(arg): | |||
def escape_argument(arg, escape=True): | |||
''' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add this new parameter to the docs for this function
Ping @ciiqr The original coder of windows escape. |
Why do we need |
This fix seems reasonable, I doubt I ever tested with cmd set as the shell, so I'm not surprised it's wrong for that case. |
What does this PR do?
Adds the cmdmod module integration tests to run on windows and fixes an issue on windows when there is a space in the path name of the
cwd
argument.Given this state file:
When run I see this error:
If i use the powershell shell it works:
The reason this is occurring is because it tries to escape the quotes around the command leaving hte space unescaped. So the resulting command is this:
chcp 437 > nul & ^"c:\test 2\__salt.tmp.al96jv.py^"
and if run in cmd.exe:Also fixes an issue when it it attempts to clean the temp file here: https://github.com/saltstack/salt/blob/v2017.7.7/salt/modules/cmdmod.py#L2141
it cannot delete the temp file because it quotes the path
'"<path>"'
and whne it checks to see if its a valid path it fails. So this ensures we are using the inital path created from here: https://github.com/saltstack/salt/blob/v2017.7.7/salt/modules/cmdmod.py#L2084Also this PR changes the expected return in windows on the tests so I could use some review if those returns are expected behavior or not.
What issues does this PR fix or reference?
#44997
Tests written?
Yes - adds tests and fixes something a test found
Commits signed with GPG?
Yes