From 6dbc443f8acfb262ca1ab263b60ecb801c00aac2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 1 May 2021 06:21:17 +0000 Subject: lei edit-search: support relocating lei.q.output The contents of the old lei.q.output will not be removed, but will be converted into the new one. --- script/lei | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'script') diff --git a/script/lei b/script/lei index 90a93839..bec6b001 100755 --- a/script/lei +++ b/script/lei @@ -33,8 +33,15 @@ my $exec_cmd = sub { push @rdr, shift(@old), $newfh; } my $do_exec = sub { + my @non_std; # ex. $op_p from lei_edit_search while (my ($io, $newfh) = splice(@rdr, 0, 2)) { + my $old_io = !!$io; open $io, '+<&', $newfh or die "open +<&=: $!"; + push @non_std, $io unless $old_io; + } + if (@non_std) { + require Fcntl; + fcntl($_, Fcntl::F_SETFD(), 0) for @non_std; } my %env = map { split(/=/, $_, 2) } splice(@argv, $argc); @ENV{keys %env} = values %env; -- cgit v1.2.3-24-ge0c7