[PATCH] tar: allow creating empty archive when -T is set
Sertonix
sertonix at posteo.net
Wed Jan 29 21:39:08 UTC 2025
This matches the GNU tar behaviour. Usefull when something needs to be
tarball but shouldn't contain any files.
function old new delta
tar_main 1272 1278 +6
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/0 up/down: 6/0) Total: 6 bytes
---
archival/tar.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/archival/tar.c b/archival/tar.c
index d6ca6c1e0..3983fb36e 100644
--- a/archival/tar.c
+++ b/archival/tar.c
@@ -1139,8 +1139,8 @@ int tar_main(int argc UNUSED_PARAM, char **argv)
int flags = O_RDONLY;
if (opt & OPT_CREATE) {
- /* Make sure there is at least one file to tar up */
- if (tar_handle->accept == NULL)
+ /* Make sure there is at least one file to tar up when not using -T */
+ if (tar_handle->accept == NULL && !(opt & OPT_INCLUDE_FROM))
bb_simple_error_msg_and_die("empty archive");
tar_fd = STDOUT_FILENO;
--
2.48.1
More information about the busybox
mailing list