mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Merge pull request #45134 from garethgreenaway/44315_cmd_script_cwd_with_space
[2017.7] fix to cmd.script for cwd with space
This commit is contained in:
commit
a1946730a9
2 changed files with 27 additions and 1 deletions
|
@ -2146,6 +2146,9 @@ def script(source,
|
|||
if not salt.utils.is_windows():
|
||||
os.chmod(path, 320)
|
||||
os.chown(path, __salt__['file.user_to_uid'](runas), -1)
|
||||
|
||||
path = _cmd_quote(path)
|
||||
|
||||
ret = _run(path + ' ' + str(args) if args else path,
|
||||
cwd=cwd,
|
||||
stdin=stdin,
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
from __future__ import absolute_import
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import textwrap
|
||||
|
||||
# Import Salt Testing libs
|
||||
|
@ -13,6 +14,7 @@ from tests.support.helpers import (
|
|||
skip_if_binaries_missing,
|
||||
skip_if_not_root
|
||||
)
|
||||
from tests.support.paths import TMP
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils
|
||||
|
@ -20,7 +22,6 @@ import salt.utils
|
|||
# Import 3rd-party libs
|
||||
import salt.ext.six as six
|
||||
|
||||
|
||||
AVAILABLE_PYTHON_EXECUTABLE = salt.utils.which_bin([
|
||||
'python',
|
||||
'python2',
|
||||
|
@ -139,6 +140,28 @@ class CMDModuleTest(ModuleCase):
|
|||
ret = self.run_function('cmd.script_retcode', [script])
|
||||
self.assertEqual(ret, 0)
|
||||
|
||||
def test_script_cwd(self):
|
||||
'''
|
||||
cmd.script with cwd
|
||||
'''
|
||||
tmp_cwd = tempfile.mkdtemp(dir=TMP)
|
||||
args = 'saltines crackers biscuits=yes'
|
||||
script = 'salt://script.py'
|
||||
ret = self.run_function('cmd.script', [script, args], cwd=tmp_cwd)
|
||||
self.assertEqual(ret['stdout'], args)
|
||||
|
||||
def test_script_cwd_with_space(self):
|
||||
'''
|
||||
cmd.script with cwd
|
||||
'''
|
||||
tmp_cwd = "{0}{1}test 2".format(tempfile.mkdtemp(dir=TMP), os.path.sep)
|
||||
os.mkdir(tmp_cwd)
|
||||
|
||||
args = 'saltines crackers biscuits=yes'
|
||||
script = 'salt://script.py'
|
||||
ret = self.run_function('cmd.script', [script, args], cwd=tmp_cwd)
|
||||
self.assertEqual(ret['stdout'], args)
|
||||
|
||||
@destructiveTest
|
||||
def test_tty(self):
|
||||
'''
|
||||
|
|
Loading…
Add table
Reference in a new issue