Skip to content

Instantly share code, notes, and snippets.

@jduck
Last active July 31, 2016 08:05
Show Gist options
  • Save jduck/37134373216aedf17323bae2ca049d2a to your computer and use it in GitHub Desktop.
Save jduck/37134373216aedf17323bae2ca049d2a to your computer and use it in GitHub Desktop.
diff --git a/adb/commandline.cpp b/adb/commandline.cpp
index a856672..a524df6 100644
--- a/adb/commandline.cpp
+++ b/adb/commandline.cpp
@@ -605,11 +605,17 @@ static std::string ShellServiceString(bool use_shell_protocol,
args.push_back(type_arg);
}
+ const char *cmd;
+ if (command.empty())
+ cmd = "cd /data/local/tmp && sh";
+ else
+ cmd = command.c_str();
+
// Shell service string can look like: shell[,arg1,arg2,...]:[command].
return android::base::StringPrintf("shell%s%s:%s",
args.empty() ? "" : ",",
android::base::Join(args, ',').c_str(),
- command.c_str());
+ cmd);
}
// Connects to a shell on the device and read/writes data.
@@ -761,6 +767,9 @@ static int adb_shell(int argc, const char** argv) {
std::string shell_type_arg;
if (CanUseFeature(features, kFeatureShell2)) {
+ // Default to PTY if the device supports this feature.
+ shell_type_arg = kShellServiceArgPty;
+
if (t_arg_count < 0) {
shell_type_arg = kShellServiceArgRaw;
} else if (t_arg_count == 0) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment