From 6468d792bc173340cc6fafa224c7ceac5a4b089b Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Wed, 9 Oct 2013 11:13:50 -0400 Subject: [PATCH] do not mangle the command if it needs sudo --- remoto/tests/test_util.py | 4 ++++ remoto/util.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/remoto/tests/test_util.py b/remoto/tests/test_util.py index 4ecfb7d..1640695 100644 --- a/remoto/tests/test_util.py +++ b/remoto/tests/test_util.py @@ -10,3 +10,7 @@ class TestAdminCommand(object): def test_skip_prepend_if_not_sudo(self): result = util.admin_command(False, ['ls']) assert result == ['ls'] + + def test_command_that_is_not_a_list(self): + result = util.admin_command(True, 'ls') + assert result == ['sudo', 'ls'] diff --git a/remoto/util.py b/remoto/util.py index 63b1bc0..6098ac7 100644 --- a/remoto/util.py +++ b/remoto/util.py @@ -10,5 +10,7 @@ def admin_command(sudo, command): :param command: A list of the actual command to execute with Popen. """ if sudo: - command.insert(0, 'sudo') + if not isinstance(command, list): + command = [command] + return ['sudo'] + [cmd for cmd in command] return command -- 2.47.3