Skip to content

ADBDeviceExt::shell_command: misleading API #136

@lem-solutions

Description

@lem-solutions

ADBDeviceExt::shell_command accepts &[&str] as command, which makes it seem that the user can pass distinct cli arguments to the invoked command, meaning the 0th element is the program to be invoked, the first element is the first cli argument, the second element is the second cli arg, etc.

This is not actually the case since the function just joins the elements with spaces, eg. passing &["touch","a b"] would not touch the file "a b" but touch both "a" and "b". This problem manifests also in reverse eg. &["touch","\"", "hello", "world", "\""] would touch " hello world ".

Since getting all the weirdness of shell escaping correct is very difficult I'd suggest just accepting &str instead. Note that this would be breaking API so you'd need to bump the major version number or deprecate ADBDeviceExt::shell_command and add a new function.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions