From df8e76a67ce6fdd469dc2782819f3c9081a0f8ac Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Thu, 25 Apr 2019 16:01:28 +0200 Subject: [PATCH] cat: Just use fd 0 when no arguments are passed. I'm not sure why it seemed necessary at some point to open /dev/stdin rather than simply using the already-open fd 0. --- Userland/cat.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Userland/cat.cpp b/Userland/cat.cpp index 5454d7e982..d084b532ed 100644 --- a/Userland/cat.cpp +++ b/Userland/cat.cpp @@ -8,10 +8,9 @@ int main(int argc, char** argv) { - const char* input_file = argc > 1 ? argv[1] : "/dev/stdin"; - int fd = open(input_file, O_RDONLY); + int fd = argc > 1 ? open(argv[1], O_RDONLY) : 0; if (fd == -1) { - printf("failed to open %s: %s\n", input_file, strerror(errno)); + printf("failed to open %s: %s\n", argv[1], strerror(errno)); return 1; } for (;;) {