From a04cc47f1c53c34e81a7271d687d8b68d0489892 Mon Sep 17 00:00:00 2001 From: Denis Vlasenko Date: Wed, 25 Jun 2008 20:54:45 +0000 Subject: [PATCH] b[un]zip2, g[un]zip: unlink destination if -f is given. Closes 3854 --- archival/bbunzip.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/archival/bbunzip.c b/archival/bbunzip.c index 90d39f682..09a4eb9eb 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c @@ -73,6 +73,12 @@ int bbunpack(char **argv, bb_error_msg("%s: unknown suffix - ignored", filename); goto err; } + + /* -f: overwrite existing output files */ + if (option_mask32 & OPT_FORCE) { + unlink(new_name); + } + /* O_EXCL: "real" bunzip2 doesn't overwrite files */ /* GNU gunzip does not bail out, but goes to next file */ if (open_to_or_warn(STDOUT_FILENO, new_name, O_WRONLY | O_CREAT | O_EXCL, -- 2.25.1