summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-06-01 09:13:17 +0200
committerAndreas Kling <kling@serenityos.org>2021-06-01 09:13:17 +0200
commitd105747735357b37e968ded71532528426d60763 (patch)
treed7bdb6c5313aab292a4f8113e44248060fac135f /Userland/Utilities
parent9388cf327f10c191490d0b9ee2493d950f88a2f6 (diff)
downloadserenity-d105747735357b37e968ded71532528426d60763.zip
basename: Tidy up a little more
This looks a little nicer with a single outln() invocation. :^)
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/basename.cpp11
1 files changed, 6 insertions, 5 deletions
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;
}