parent
b8908f2dc6
commit
471c75d738
|
@ -7,6 +7,7 @@
|
||||||
#include "shell_manager.hh"
|
#include "shell_manager.hh"
|
||||||
#include "utils.hh"
|
#include "utils.hh"
|
||||||
#include "optional.hh"
|
#include "optional.hh"
|
||||||
|
#include "containers.hh"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
@ -250,9 +251,22 @@ String expand_token(const Token& token, const Context& context,
|
||||||
switch (token.type())
|
switch (token.type())
|
||||||
{
|
{
|
||||||
case Token::Type::ShellExpand:
|
case Token::Type::ShellExpand:
|
||||||
return ShellManager::instance().eval(content, context, {},
|
{
|
||||||
ShellManager::Flags::WaitForStdout,
|
auto str = ShellManager::instance().eval(
|
||||||
shell_context).first;
|
content, context, {}, ShellManager::Flags::WaitForStdout,
|
||||||
|
shell_context).first;
|
||||||
|
|
||||||
|
int trailing_eol_count = 0;
|
||||||
|
for (auto c : str | reverse())
|
||||||
|
{
|
||||||
|
if (c != '\n')
|
||||||
|
break;
|
||||||
|
++trailing_eol_count;
|
||||||
|
}
|
||||||
|
str.resize(str.length() - trailing_eol_count, 0);
|
||||||
|
return str;
|
||||||
|
|
||||||
|
}
|
||||||
case Token::Type::RegisterExpand:
|
case Token::Type::RegisterExpand:
|
||||||
return context.main_sel_register_value(content).str();
|
return context.main_sel_register_value(content).str();
|
||||||
case Token::Type::OptionExpand:
|
case Token::Type::OptionExpand:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user