shithub: hx

Download patch

ref: fe80726c19afaff3021994f66107a21baf1efa01
parent: fd724962d1f6d325da44fc2db7425939f8fde79e
author: Sigrid Haflínudóttir <ftrvxmtrx@gmail.com>
date: Wed Feb 19 15:21:06 EST 2020

dump stdin if no arguments provided

--- a/README.md
+++ b/README.md
@@ -20,5 +20,4 @@
 
 # Notes
 
- * `echo blah | hx` won't print anything, use `echo blah | hx /dev/stdin` instead.
  * hx will print data as soon as it is available (if used on pipes), without buffering.
--- a/hx.c
+++ b/hx.c
@@ -165,6 +165,11 @@
 	}
 
 	res = 0;
+	if (argc == 1) {
+		i = 1;
+		fd = 0;
+		goto dump;
+	}
 	for (i = 1; i < argc && res == 0; i++) {
 		if ((fd = open(argv[i], OREAD)) < 0) {
 			perror(argv[i]);
@@ -175,6 +180,7 @@
 				write(1, argv[i], strlen(argv[i]));
 				write(1, "\n", 1);
 			}
+dump:
 			if ((res = hx(fd)) != 0)
 				perror(argv[1]);
 			close(fd);