9 command1 | vipe | command2
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. Your editor will
15 have the full data being piped from command1 loaded into it, and when you
16 close it, that data will be piped into command2.
18 =head1 ENVIRONMENT VARIABLES
28 Also supported to determine what editor to use.
34 Copyright 2006 by Joey Hess <joey@kitenet.net>
36 Licensed under the GNU GPL.
42 use File
::Temp
q{tempfile};
46 my ($fh, $tmp)=tempfile
();
47 die "cannot create tempfile" unless $fh;
48 print ($fh <STDIN
>) || die "write temp: $!";
51 open(STDIN
, "</dev/tty") || die "reopen stdin: $!";
52 open(OUT
, ">&STDOUT") || die "save stdout: $!";
54 open(STDOUT
, ">/dev/tty") || die "reopen stdout: $!";
57 if (-x
"/usr/bin/editor") {
58 @editor="/usr/bin/editor";
60 if (exists $ENV{EDITOR
}) {
61 @editor=split(' ', $ENV{EDITOR
});
63 if (exists $ENV{VISUAL
}) {
64 @editor=split(' ', $ENV{VISUAL
});
66 my $ret=system(@editor, $tmp);
68 die "@editor exited nonzero, aborting\n";
71 open (IN
, $tmp) || die "$0: cannot read $tmp: $!\n";
72 print (OUT
<IN
>) || die "write failure: $!";