mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-22 17:31:58 -05:00
dirname: Add -z
option for null terminated output
This commit is contained in:
parent
c1c35f4f59
commit
828caf12a6
1 changed files with 6 additions and 2 deletions
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
|
||||
* Copyright (c) 2023, Tim Ledbetter <timledbetter@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -10,11 +11,14 @@
|
|||
|
||||
ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||
{
|
||||
DeprecatedString path = {};
|
||||
bool null_terminated = false;
|
||||
DeprecatedString path;
|
||||
Core::ArgsParser args_parser;
|
||||
args_parser.add_option(null_terminated, "End each output line with \\0, rather than \\n", "zero", 'z');
|
||||
args_parser.add_positional_argument(path, "Path", "path");
|
||||
args_parser.parse(arguments);
|
||||
|
||||
outln("{}", LexicalPath::dirname(path));
|
||||
auto const delimiter = null_terminated ? '\0' : '\n';
|
||||
out("{}{}", LexicalPath::dirname(path), delimiter);
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue