From a96c69e45428a13b0e16a4fc332694e9f791b24d Mon Sep 17 00:00:00 2001
From: dzwdz
Date: Sun, 4 Sep 2022 11:37:31 +0200
Subject: user/shell: use perror

---
 src/user/app/shell/builtins.c | 4 ++--
 src/user/app/shell/shell.c    | 3 +--
 2 files changed, 3 insertions(+), 4 deletions(-)

(limited to 'src/user/app')

diff --git a/src/user/app/shell/builtins.c b/src/user/app/shell/builtins.c
index 0098773..bc7731c 100644
--- a/src/user/app/shell/builtins.c
+++ b/src/user/app/shell/builtins.c
@@ -24,7 +24,7 @@ static void cmd_cat(int argc, char **argv) {
 	for (int i = 1; i < argc; i++) {
 		FILE *file = fopen(argv[i], "r");
 		if (!file) {
-			eprintf("couldn't open %s", argv[i]);
+			perror(argv[i]);
 			return;
 		}
 		if (!strcmp(argv[i], "!stdin")) fextflags(file, FEXT_NOFILL);
@@ -227,7 +227,7 @@ static void cmd_touch(int argc, char **argv) {
 
 	for (int i = 1; i < argc; i++) {
 		FILE *f = fopen(argv[i], "a");
-		if (!f) eprintf("couldn't touch %s\n", argv[i]);
+		if (!f) perror(argv[i]);
 		fclose(f);
 	}
 }
diff --git a/src/user/app/shell/shell.c b/src/user/app/shell/shell.c
index 0c92410..290102e 100644
--- a/src/user/app/shell/shell.c
+++ b/src/user/app/shell/shell.c
@@ -50,8 +50,7 @@ void run_args(int argc, char **argv, struct redir *redir) {
 		return;
 	} else if (!strcmp(argv[0], "cd")) {
 		if (chdir(argc > 1 ? argv[1] : "/") < 0)
-			eprintf("error");
-		// TODO strerror
+			perror("cd");
 		return;
 	} else if (!strcmp(argv[0], "time")) {
 		uint64_t time = __rdtsc();
-- 
cgit v1.2.3