Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Update run/sudo combine_stderr for overriding.
Fixes fabric#324.
  • Loading branch information
bitprophet committed May 31, 2011
1 parent ef696c3 commit 851b796
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 5 additions & 0 deletions docs/changes/1.0.2.rst
Expand Up @@ -7,6 +7,11 @@ Bugfixes

* :issue:`258`: Bugfix to a previous, incorrectly applied fix regarding
`~fabric.operations.local` on Windows platforms.
* :issue:`324`: Update `~fabric.operations.run`/`~fabric.operations.sudo`'s
``combine_stderr`` kwarg so that it correctly overrides the global setting in
all cases. This required changing its default value to ``None``, but the
default behavior (behaving as if the setting were ``True``) has not changed.
Thanks to Matthew Woodcraft and Connor Smith for the catch.
* :issue:`337`: Fix logic bug in `~fabric.operations.put` preventing use of
``mirror_local_mode``. Thanks to Roman Imankulov for catch & patch.

Expand Down
15 changes: 12 additions & 3 deletions fabric/operations.py
Expand Up @@ -694,14 +694,17 @@ def _prefix_env_vars(command):
return path + command


def _execute(channel, command, pty=True, combine_stderr=True,
def _execute(channel, command, pty=True, combine_stderr=None,
invoke_shell=False):
"""
Execute ``command`` over ``channel``.
``pty`` controls whether a pseudo-terminal is created.
``combine_stderr`` controls whether we call ``channel.set_combine_stderr``.
By default, the global setting for this behavior (:ref:`env.combine_stderr
<combine-stderr>`) is consulted, but you may specify ``True`` or ``False``
here to override it.
``invoke_shell`` controls whether we use ``exec_command`` or
``invoke_shell`` (plus a handful of other things, such as always forcing a
Expand All @@ -713,8 +716,9 @@ def _execute(channel, command, pty=True, combine_stderr=True,
"""
with char_buffered(sys.stdin):
# Combine stdout and stderr to get around oddball mixing issues
if combine_stderr or env.combine_stderr:
channel.set_combine_stderr(True)
if combine_stderr is None:
combine_stderr = env.combine_stderr
channel.set_combine_stderr(combine_stderr)

# Assume pty use, and allow overriding of this either via kwarg or env
# var. (invoke_shell always wants a pty no matter what.)
Expand Down Expand Up @@ -914,6 +918,11 @@ def run(command, shell=True, pty=True, combine_stderr=True):
.. versionchanged:: 1.0
The default value of ``pty`` is now ``True``.
.. versionchanged:: 1.0.2
The default value of ``combine_stderr`` is now ``None`` instead of
``True``. However, the default *behavior* is unchanged, as the global
setting is still ``True``.
"""
return _run_command(command, shell, pty, combine_stderr)

Expand Down

0 comments on commit 851b796

Please sign in to comment.