gunzip: Don't truncate output filename when input file suffix is omitted
Before this commit, `$ gunzip abcd` would incorrectly uncompress `abcd.gz` to `a` instead of to `abcd`.
This commit is contained in:
parent
e8ae0541d9
commit
5f639493f0
Notes:
sideshowbarker
2024-07-17 20:22:28 +09:00
Author: https://github.com/Rummskartoffel Commit: https://github.com/SerenityOS/serenity/commit/5f639493f03 Pull-request: https://github.com/SerenityOS/serenity/pull/11995 Reviewed-by: https://github.com/AtkinsSJ ✅
1 changed files with 6 additions and 4 deletions
|
@ -43,12 +43,14 @@ ErrorOr<int> serenity_main(Main::Arguments args)
|
|||
for (auto filename : filenames) {
|
||||
|
||||
String input_filename;
|
||||
if (filename.ends_with(".gz"))
|
||||
String output_filename;
|
||||
if (filename.ends_with(".gz")) {
|
||||
input_filename = filename;
|
||||
else
|
||||
output_filename = filename.substring_view(0, filename.length() - 3);
|
||||
} else {
|
||||
input_filename = String::formatted("{}.gz", filename);
|
||||
|
||||
const auto output_filename = filename.substring_view(0, filename.length() - 3);
|
||||
output_filename = filename;
|
||||
}
|
||||
|
||||
auto input_stream_result = TRY(Core::InputFileStream::open_buffered(input_filename));
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue