summaryrefslogtreecommitdiff
path: root/src/shell_manager.hh
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2024-08-26 21:00:08 +1000
committerMaxime Coste <mawww@kakoune.org>2024-08-26 21:00:08 +1000
commit9275d965a6952d44035fd0502ee0d3991352c460 (patch)
treec3a0abf7b582c3bc53a492c1e1d3dbc72d215879 /src/shell_manager.hh
parent202747e68896aebbe38cc160391629e020f0c2a1 (diff)
Do not gather full input data in a single string when piping
Refactor ShellManager and pipe to feed lines from the buffer directly, this should reduce memory use when piping big chunks of buffers. The pipe output is still provided as a single big buffer.
Diffstat (limited to 'src/shell_manager.hh')
-rw-r--r--src/shell_manager.hh12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/shell_manager.hh b/src/shell_manager.hh
index f6ef38a4..3dc62e0a 100644
--- a/src/shell_manager.hh
+++ b/src/shell_manager.hh
@@ -58,10 +58,20 @@ public:
friend constexpr bool with_bit_ops(Meta::Type<Flags>) { return true; }
std::pair<String, int> eval(StringView cmdline, const Context& context,
- StringView input = {},
+ FunctionRef<StringView ()> stdin_generator,
Flags flags = Flags::WaitForStdout,
const ShellContext& shell_context = {});
+ std::pair<String, int> eval(StringView cmdline, const Context& context,
+ StringView stdin,
+ Flags flags = Flags::WaitForStdout,
+ const ShellContext& shell_context = {})
+ {
+ return eval(cmdline, context,
+ [stdin]() mutable { return std::exchange(stdin, StringView{}); },
+ flags, shell_context);
+ }
+
Shell spawn(StringView cmdline,
const Context& context,
bool open_stdin,