sbase

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

commit 5dc02f757bd528e666534cd6492c7c61cdf1a6e4
parent a62eda512c688e4dada99cba21788cb67258512b
Author: sin <sin@2f30.org>
Date:   Fri,  4 Jul 2014 16:45:20 +0100

Add support for '-' to cat

This chunk will need to be librarified at some point.

Diffstat:
Mcat.c | 8++++++--
1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/cat.c b/cat.c @@ -15,6 +15,7 @@ usage(void) int main(int argc, char *argv[]) { + char *p; FILE *fp; int i; @@ -27,11 +28,14 @@ main(int argc, char *argv[]) concat(stdin, "<stdin>", stdout, "<stdout>"); } else { for(i = 0; i < argc; i++) { - if(!(fp = fopen(argv[i], "r"))) { + p = argv[i]; + if (argv[i][0] == '-') + p = "/dev/stdin"; + if(!(fp = fopen(p, "r"))) { weprintf("fopen %s:", argv[i]); continue; } - concat(fp, argv[i], stdout, "<stdout>"); + concat(fp, p, stdout, "<stdout>"); fclose(fp); } }