summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-02-03 12:38:03 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-02-03 12:38:03 +0100
commit31f44481f3e3fef9b3a92d28ae84a872cf20e3a9 (patch)
tree4e2b51bdbd14c11bb39b9156624ffb2bea5143bf /Userland
parent5e9ba2ac84ca4766111b1845ca07fc32872e82fc (diff)
downloadserenity-31f44481f3e3fef9b3a92d28ae84a872cf20e3a9.zip
Add /dev/{stdin,stdout,stderr} as symlinks to /proc/self/fd/{0,1,2}
Also change /bin/cat to open /dev/stdin if no arguments are provided.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/cat.cpp9
1 files changed, 3 insertions, 6 deletions
diff --git a/Userland/cat.cpp b/Userland/cat.cpp
index 4a5162a41a..5454d7e982 100644
--- a/Userland/cat.cpp
+++ b/Userland/cat.cpp
@@ -8,13 +8,10 @@
int main(int argc, char** argv)
{
- if (argc != 2) {
- printf("usage: cat <file>\n");
- return 1;
- }
- int fd = open(argv[1], O_RDONLY);
+ const char* input_file = argc > 1 ? argv[1] : "/dev/stdin";
+ int fd = open(input_file, O_RDONLY);
if (fd == -1) {
- printf("failed to open %s: %s\n", argv[1], strerror(errno));
+ printf("failed to open %s: %s\n", input_file, strerror(errno));
return 1;
}
for (;;) {