Skip to content

Commit 7c43fd0

Browse files
Treehugger Robotcjreynol
authored andcommitted
[skip ci] Merge "Add ToString method to command" into main
GitOrigin-RevId: b0a3c52
1 parent 4e889a4 commit 7c43fd0

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

staging/common/libs/utils/subprocess.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -482,6 +482,16 @@ Subprocess Command::Start(SubprocessOptions options) const {
482482
return Subprocess(pid, subprocess_stopper_);
483483
}
484484

485+
std::string Command::ToString() const {
486+
std::stringstream ss;
487+
if (!env_.empty()) {
488+
ss << android::base::Join(env_, " ");
489+
ss << " ";
490+
}
491+
ss << android::base::Join(command_, " ");
492+
return ss.str();
493+
}
494+
485495
std::string Command::AsBashScript(
486496
const std::string& redirected_stdio_path) const {
487497
CHECK(inherited_fds_.empty())

staging/common/libs/utils/subprocess.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,8 @@ class Command {
304304
return command_[0];
305305
}
306306

307+
std::string ToString() const;
308+
307309
// Generates the contents for a bash script that can be used to run this
308310
// command. Note that this command must not require any file descriptors
309311
// or stdio redirects as those would not be available when the bash script

0 commit comments

Comments
 (0)