summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joeyh@joeyh.name>2021-02-04 16:29:08 -0400
committerJoey Hess <joeyh@joeyh.name>2021-02-04 16:29:08 -0400
commit4e0a7d96bf944979d6eea3fc764dce1bb18779a2 (patch)
tree2b593bd071b0275a67a80a21dbc36181f7cb4c5c
parent54cb31ec6086f9db1c5f76ff2a1017cf272b320a (diff)
downloadmoreutils-4e0a7d96bf944979d6eea3fc764dce1bb18779a2.tar.gz
skip reading from stdin when it's a tty
vipe: When no output is piped into vipe, and stdin is connected to the terminal, don't read from stdin before opening the editor. This allows eg: vipe | command Thanks, Florian Pensec
-rw-r--r--debian/changelog9
-rwxr-xr-xvipe4
2 files changed, 12 insertions, 1 deletions
diff --git a/debian/changelog b/debian/changelog
index 8ec91c4..10f84a1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,12 @@
+moreutils (0.66) UNRELEASED; urgency=medium
+
+ * vipe: When no output is piped into vipe, and stdin is connected to
+ the terminal, don't read from stdin before opening the editor.
+ This allows eg: vipe | command
+ Thanks, Florian Pensec
+
+ -- Joey Hess <id@joeyh.name> Thu, 04 Feb 2021 16:27:16 -0400
+
moreutils (0.65) unstable; urgency=medium
* vipe: Added --suffix option.
diff --git a/vipe b/vipe
index 548fbed..9daaec5 100755
--- a/vipe
+++ b/vipe
@@ -64,7 +64,9 @@ $suffix = ".$suffix" if $suffix =~ m/^[^.]/;
my ($fh, $tmp)=tempfile(UNLINK => 1, SUFFIX => $suffix);
die "cannot create tempfile" unless $fh;
-print ($fh <STDIN>) || die "write temp: $!";
+if (! -t STDIN) {
+ print ($fh <STDIN>) || die "write temp: $!";
+}
close $fh;
close STDIN;
open(STDIN, "</dev/tty") || die "reopen stdin: $!";