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
22 Editor to use. Defaults to vi if not set.
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 (exists $ENV{EDITOR
}) {
58 if (exists $ENV{VISUAL
}) {
61 my $ret=system($editor, $tmp);
63 die "$editor exited nonzero, aborting\n";
66 open (IN
, $tmp) || die "$0: cannot read $tmp: $!\n";
67 print OUT
<IN
> || die "write failure: $!";