Skip to content

Conversation

@twangboy
Copy link
Contributor

@twangboy twangboy commented Nov 3, 2025

What does this PR do?

Reverts part of #68156 that changed the default behavior for python_shell and shell. Also fixes a bug in the PR mentioned above, where you couldn't pass non-list parameters to a script.

What issues does this PR fix or reference?

Fixes #68156

Merge requirements satisfied?

[NOTICE] Bug fixes or features added to Salt require tests.

Commits signed with GPG?

Yes

Comment on lines 58 to 65
from salt.utils.win_functions import shlex_split
from salt.utils.win_runas import runas as win_runas

HAS_WIN_RUNAS = True
else:
import shlex

_cmd_quote = shlex.quote
Copy link
Contributor

@bdrx312 bdrx312 Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe do the same thing for split as was done for _cmd_quote to avoid having to check salt.utils.platform.is_windows on every usage of shlex.split.

Comment on lines 38 to 45
@pytest.mark.skip_on_freebsd
def test_shell_enabled(self):
def test_shell_disabled(self):
"""
test shell enabled output for cmd.run
test shell disabled output for cmd.run
"""
enabled_ret = "3\nsaltines" # the result of running self.cmd in a shell
ret = self.run_function("cmd.run", [self.cmd], python_shell=True)
self.assertEqual(ret.strip(), enabled_ret)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like it would be good to also have test_shell_enabled test in addition to test_shell_disabled instead of replacing it with test_shell_disabled

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original test was for disabled... I can add a test for enabled as well

Comment on lines 35 to 36
@pytest.mark.skip_on_windows(reason="Skip on Windows OS")
@pytest.mark.skip_on_freebsd
def test_shell_enabled(self):
def test_shell_disabled(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would good be good to have a test for windows to ensure the expected behavior occurs when python_shell=False is passed on windows.

@jonaschl
Copy link

jonaschl commented Nov 4, 2025

Is this a fix to #68298 ? If yes, thanks, as this regression has broken some code of mine.

Comment on lines +113 to +115
elif __opts__.get("cmd_safe", True) is False and python_shell is None:
# Override-switch for python_shell
return True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any tests for cmd_safe? I did a quick search and did not notice any.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There were none before it was removed in #68156

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test:full Run the full test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants