mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-24 10:12:25 -05:00
Terminal: Add -d option for specifying working directory
This commit is contained in:
parent
7967c80222
commit
bbe50577f8
Notes:
sideshowbarker
2024-07-19 08:17:40 +09:00
Author: https://github.com/itamar8910 🔰 Commit: https://github.com/SerenityOS/serenity/commit/bbe50577f8a Pull-request: https://github.com/SerenityOS/serenity/pull/1467
1 changed files with 10 additions and 1 deletions
|
@ -197,12 +197,21 @@ int main(int argc, char** argv)
|
|||
}
|
||||
|
||||
const char* command_to_execute = nullptr;
|
||||
const char* working_directory_chars = nullptr;
|
||||
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_option(command_to_execute, "Execute this command inside the terminal", nullptr, 'e', "command");
|
||||
args_parser.add_option(working_directory_chars, "Set the working directory", nullptr, 'd', "directory");
|
||||
|
||||
args_parser.parse(argc, argv);
|
||||
|
||||
if (chdir(get_current_user_home_path().characters()) < 0)
|
||||
String working_directory(working_directory_chars);
|
||||
|
||||
if (working_directory.is_empty()) {
|
||||
working_directory = get_current_user_home_path();
|
||||
}
|
||||
|
||||
if (chdir(working_directory.characters()) < 0)
|
||||
perror("chdir");
|
||||
|
||||
int ptm_fd = posix_openpt(O_RDWR | O_CLOEXEC);
|
||||
|
|
Loading…
Add table
Reference in a new issue