History

dump stdin if no arguments provided

Sigrid Haflínudóttir committed 6 years ago

Commit fe807261 parent fd724962 files · +6 −1Browse files

Unified · Split

2 files
  1. README.md +0 −1
  2. hx.c +6 −0
README.md+0−1
@@ -20,5 +20,4 @@ Plan 9: `cd /tmp && hget https://github.com/ftrvxmtrx/hx/archive/master.tar.gz | · 19 unmodified lines
2020
2121 # Notes
2222
23− * `echo blah | hx` won't print anything, use `echo blah | hx /dev/stdin` instead.
2423 * hx will print data as soon as it is available (if used on pipes), without buffering.
hx.c+6−0
@@ -165,6 +165,11 @@ main(int argc, char **argv) · 164 unmodified lines
165165 }
166166
167167 res = 0;
168+ if (argc == 1) {
169+ i = 1;
170+ fd = 0;
171+ goto dump;
172+ }
168173 for (i = 1; i < argc && res == 0; i++) {
169174 if ((fd = open(argv[i], OREAD)) < 0) {
170175 perror(argv[i]);
@@ -175,6 +180,7 @@ main(int argc, char **argv) · 4 unmodified lines
175180 write(1, argv[i], strlen(argv[i]));
176181 write(1, "\n", 1);
177182 }
183+dump:
178184 if ((res = hx(fd)) != 0)
179185 perror(argv[1]);
180186 close(fd);

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t