sbase

suckless unix tools
git clone git://git.suckless.org/sbase
Log | Files | Refs | README | LICENSE

commit d208659414798cd47652a5aac67b4df8abfc380d
parent 49c91462b37ac87d182b0dcaf3493944a7ff7054
Author: sin <sin@2f30.org>
Date:   Thu, 13 Nov 2014 15:38:39 +0000

Add "-" support to comm(1)

Diffstat:
Mcomm.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/comm.c b/comm.c @@ -41,6 +41,8 @@ main(int argc, char *argv[]) usage(); for(i = 0; i < LEN(fp); i++) { + if (argv[i][0] == '-') + argv[i] = "/dev/fd/0"; if(!(fp[i] = fopen(argv[i], "r"))) eprintf("comm: '%s':", argv[i]); } @@ -48,13 +50,13 @@ main(int argc, char *argv[]) for(;;) { if(diff <= 0) { if(!nextline(lines[0], sizeof(lines[0]), - fp[0], argv[0])) { + fp[0], argv[0])) { finish(1, fp[1], argv[1]); } } if(diff >= 0) { if(!nextline(lines[1], sizeof(lines[1]), - fp[1], argv[1])) { + fp[1], argv[1])) { finish(0, fp[0], argv[0]); } } @@ -89,7 +91,6 @@ nextline(char *buf, int n, FILE *f, char *name) eprintf("comm: '%s':", name); if(buf && !strchr(buf, '\n')) eprintf("comm: '%s': line too long.\n", name); - return buf; } @@ -100,6 +101,5 @@ finish(int pos, FILE *f, char *name) while(nextline(buf, sizeof(buf), f, name)) printline(pos, buf); - exit(1); }