9 command | vipe | command
13 vipe allows you to run your editor in the middle of a unix pipeline and
14 edit the data that is being piped between programs.
16 =head1 ENVIRONMENT VARIABLES
26 Also supported to determine what editor to use.
32 Copyright 2006 by Joey Hess <joey@kitenet.net>
34 Licensed under the GNU GPL.
40 use File
::Temp
q{tempfile};
44 my ($fh, $tmp)=tempfile
();
45 die "cannot create tempfile" unless $fh;
46 print $fh <STDIN
> || die "write temp: $!";
49 open(STDIN
, "</dev/tty") || die "reopen stdin: $!";
50 open(OUT
, ">&STDOUT") || die "save stdout: $!";
52 open(STDOUT
, ">/dev/tty") || die "reopen stdout: $!";
55 if (-x
"/usr/bin/editor") {
56 @editor="/usr/bin/editor";
58 if (exists $ENV{EDITOR
}) {
59 @editor=split(' ', $ENV{EDITOR
});
61 if (exists $ENV{VISUAL
}) {
62 @editor=split(' ', $ENV{VISUAL
});
64 my $ret=system(@editor, $tmp);
66 die "@editor exited nonzero, aborting\n";
69 open (IN
, $tmp) || die "$0: cannot read $tmp: $!\n";
70 print OUT
<IN
> || die "write failure: $!";