#include "sh.h" #include #include #include shell_builtin_t builtin_cd = [](int argc, char** argv) -> Result { StringView directory; os::ArgumentParser parser; parser.set_should_exit_on_bad_usage(false); parser.add_description("Change working directory (shell builtin)"_sv); parser.add_system_program_info("cd"_sv); parser.add_positional_argument(directory, "directory"_sv, false); if (!TRY(parser.parse(argc, argv))) return {}; if (!directory.is_empty()) TRY(os::FileSystem::change_directory(directory)); else { auto home = TRY(os::FileSystem::home_directory()); TRY(os::FileSystem::change_directory(home.view())); } return {}; };