summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGunnar Beutner <gunnar@beutner.name>2021-04-23 10:42:16 +0200
committerLinus Groh <mail@linusgroh.de>2021-04-23 11:33:57 +0200
commit1e5a7ca0a7f4ab8cf4de06533902a699b57a9509 (patch)
treec9eb782431a5f1aabcd2def8f0b638aee925b364
parent6a957daba4d0f4c2ac82443cd10ce6ba4c3098ab (diff)
downloadserenity-1e5a7ca0a7f4ab8cf4de06533902a699b57a9509.zip
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.
-rw-r--r--Userland/Shell/Builtin.cpp8
1 files changed, 1 insertions, 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;
}
}