diff options
author | Eric Wong <e@80x24.org> | 2023-11-12 13:12:33 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2023-11-13 00:25:02 +0000 |
commit | 47c7ef452c0984cb4f2c3662d352ae95d672b56d (patch) | |
tree | c53519ba6afca79f720e98a28de06302e7fa84a7 /lib/PublicInbox/LEI.pm | |
parent | 270715407b0e627260588170b0239d0a5eb7cde4 (diff) | |
download | public-inbox-47c7ef452c0984cb4f2c3662d352ae95d672b56d.tar.gz |
We must use a foreground process to read from terminals on stdin, otherwise weird things like lost keystrokes and EIO can happen. So take advantage of ->send_exec_cmd to spawn `cat' in the same way we spawn MUAs, pagers, `git config --edit' and `git credential' from script/lei
Diffstat (limited to 'lib/PublicInbox/LEI.pm')
-rw-r--r-- | lib/PublicInbox/LEI.pm | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 681044c8..77acb5a1 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -1577,7 +1577,15 @@ sub _stdin_cb { # PublicInbox::InputPipe::consume callback for --stdin sub slurp_stdin { my ($lei, $cb) = @_; require PublicInbox::InputPipe; - PublicInbox::InputPipe::consume($lei->{0}, \&_stdin_cb, $lei, $cb); + my $in = $lei->{0}; + if (-t $in) { # run cat via script/lei and read from it + $in = undef; + use autodie qw(pipe); + pipe($in, my $wr); + say { $lei->{2} } '# enter query, Ctrl-D when done'; + send_exec_cmd($lei, [ $lei->{0}, $wr ], ['cat'], {}); + } + PublicInbox::InputPipe::consume($in, \&_stdin_cb, $lei, $cb); } 1; |