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.
This commit is contained in:
Andreas Kling 2019-04-25 16:01:28 +02:00
parent 6c950f8f83
commit df8e76a67c
Notes: sideshowbarker 2024-07-19 14:35:37 +09:00

View File

@ -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 (;;) {