mirror of
https://github.com/ARM-software/devlib.git
synced 2025-01-31 02:00:45 +00:00
android: Fixed issue using single quoted command with adb_shell
When using 'check_exit_code' and 'as_root' options for adb_shell with a command containing single quotes, the provided command was escaped twice which has now been avoided.
This commit is contained in:
parent
a89c3fb009
commit
b59f7c360e
@ -334,14 +334,15 @@ def adb_shell(device, command, timeout=None, check_exit_code=False,
|
|||||||
_check_env()
|
_check_env()
|
||||||
if as_root:
|
if as_root:
|
||||||
command = 'echo \'{}\' | su'.format(escape_single_quotes(command))
|
command = 'echo \'{}\' | su'.format(escape_single_quotes(command))
|
||||||
device_string = ' -s {}'.format(device) if device else ''
|
device_part = ['-s', device] if device else []
|
||||||
|
device_string = ' {} {}'.format(*device_part) if device_part else ''
|
||||||
full_command = 'adb{} shell "{}"'.format(device_string,
|
full_command = 'adb{} shell "{}"'.format(device_string,
|
||||||
escape_double_quotes(command))
|
escape_double_quotes(command))
|
||||||
logger.debug(full_command)
|
logger.debug(full_command)
|
||||||
if check_exit_code:
|
if check_exit_code:
|
||||||
actual_command = "adb{} shell '({}); echo \"\n$?\"'".format(device_string,
|
adb_shell_command = '({}); echo \"\n$?\"'.format(command)
|
||||||
escape_single_quotes(command))
|
actual_command = ['adb'] + device_part + ['shell', adb_shell_command]
|
||||||
raw_output, error = check_output(actual_command, timeout, shell=True)
|
raw_output, error = check_output(actual_command, timeout, shell=False)
|
||||||
if raw_output:
|
if raw_output:
|
||||||
try:
|
try:
|
||||||
output, exit_code, _ = raw_output.rsplit(newline_separator, 2)
|
output, exit_code, _ = raw_output.rsplit(newline_separator, 2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user