From 1e5a7ca0a7f4ab8cf4de06533902a699b57a9509 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 23 Apr 2021 10:42:16 +0200 Subject: [PATCH] Shell: Fix how cd handles the path argument Previously this didn't work: $ cd -- /usr Invalid path '--' This path fixes this issue and removes the unnecessary else branch because we're already using realpath() later on to resolve relative paths. --- Userland/Shell/Builtin.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/Userland/Shell/Builtin.cpp b/Userland/Shell/Builtin.cpp index 0e94a8862a..e1fa12ba54 100644 --- a/Userland/Shell/Builtin.cpp +++ b/Userland/Shell/Builtin.cpp @@ -198,14 +198,8 @@ int Shell::builtin_cd(int argc, const char** argv) if (oldpwd == nullptr) return 1; new_path = oldpwd; - } else if (arg_path[0] == '/') { - new_path = argv[1]; } else { - StringBuilder builder; - builder.append(cwd); - builder.append('/'); - builder.append(arg_path); - new_path = builder.to_string(); + new_path = arg_path; } }