From d105747735357b37e968ded71532528426d60763 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Tue, 1 Jun 2021 09:13:17 +0200 Subject: basename: Tidy up a little more This looks a little nicer with a single outln() invocation. :^) --- Userland/Utilities/basename.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'Userland/Utilities') diff --git a/Userland/Utilities/basename.cpp b/Userland/Utilities/basename.cpp index 9932190c62..ee54a200f8 100644 --- a/Userland/Utilities/basename.cpp +++ b/Userland/Utilities/basename.cpp @@ -24,10 +24,11 @@ int main(int argc, char** argv) args_parser.add_positional_argument(suffix, "Suffix to strip from name", "suffix", Core::ArgsParser::Required::No); args_parser.parse(argc, argv); - auto basename = LexicalPath(path).basename(); - if (!suffix.is_null() && basename.length() != suffix.length() && basename.ends_with(suffix)) - outln("{}", basename.substring_view(0, basename.length() - suffix.length())); - else - outln("{}", basename); + auto result = LexicalPath(path).basename(); + + if (!suffix.is_null() && result.length() != suffix.length() && result.ends_with(suffix)) + result = result.substring(0, result.length() - suffix.length()); + + outln("{}", result); return 0; } -- cgit v1.2.3