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
20 20
21# Notes21# Notes
22 22
23 * `echo blah | hx` won't print anything, use `echo blah | hx /dev/stdin` instead.
24 * hx will print data as soon as it is available (if used on pipes), without buffering.23 * 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
165 }165 }
166 166
167 res = 0;167 res = 0;
168 if (argc == 1) {
169 i = 1;
170 fd = 0;
171 goto dump;
172 }
168 for (i = 1; i < argc && res == 0; i++) {173 for (i = 1; i < argc && res == 0; i++) {
169 if ((fd = open(argv[i], OREAD)) < 0) {174 if ((fd = open(argv[i], OREAD)) < 0) {
170 perror(argv[i]);175 perror(argv[i]);
@@ -175,6 +180,7 @@ main(int argc, char **argv) · 4 unmodified lines
175 write(1, argv[i], strlen(argv[i]));180 write(1, argv[i], strlen(argv[i]));
176 write(1, "\n", 1);181 write(1, "\n", 1);
177 }182 }
183dump:
178 if ((res = hx(fd)) != 0)184 if ((res = hx(fd)) != 0)
179 perror(argv[1]);185 perror(argv[1]);
180 close(fd);186 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