mirror of
https://github.com/ksherlock/mpw-shell.git
synced 2024-12-27 18:30:39 +00:00
remove trailing newline from sub-shell strings.
This commit is contained in:
parent
9d4340b3ac
commit
5d95f10dd8
@ -157,6 +157,14 @@ std::string subshell(const std::string &s, Environment &env, const fdmask &fds)
|
||||
}
|
||||
tmp.append(buffer, buffer + len);
|
||||
}
|
||||
|
||||
|
||||
/* if present, a trailing carriage return is stripped */
|
||||
|
||||
if (!tmp.empty()) {
|
||||
if (tmp.back() == '\r' || tmp.back() == '\n') tmp.pop_back();
|
||||
}
|
||||
|
||||
std::transform(tmp.begin(), tmp.end(), tmp.begin(), [](uint8_t x){
|
||||
if (x == '\r' || x == '\n') x = ' ';
|
||||
return x;
|
||||
|
Loading…
Reference in New Issue
Block a user