diff --git a/NEWS.md b/NEWS.md index 7e87df92..6a867968 100644 --- a/NEWS.md +++ b/NEWS.md @@ -7,10 +7,10 @@ or ~/.config/tarsnap/tarsnap.conf if $XDG_CONFIG_HOME is not set. The previous config file ~/.tarsnaprc is still supported, and will not be deprecated. -- tarsnap now permits --null with --list-archives, separating each archive - name with a null character (like `find -print0`). If one or more -v - arguments are specified, multiple null characters are used to separate - fields; see the man page for details. +- tarsnap now accepts --null-output, which causes --list-archives to separate + each archive name with a null character (like `find -print0`). If one or + more -v arguments are specified, multiple null characters are used to + separate fields; see the man page for details. - tarsnap now accepts --hashes, which causes --list-archives to print hashes of archive names. If one or more -v arguments are specified, it will print other metadata (as per --list-archives). This option is intended for the diff --git a/misc/bash_completion.d/tarsnap b/misc/bash_completion.d/tarsnap index 50ce3a5d..4887d919 100644 --- a/misc/bash_completion.d/tarsnap +++ b/misc/bash_completion.d/tarsnap @@ -68,9 +68,9 @@ _tarsnap () --no-progress-bytes --no-quiet --no-retry-forever \ --no-snaptime --no-store-atime --no-totals --nodump \ --noisy-warnings --normalmem --nuke --null \ - --numeric-owner --one-file-system --passphrase \ - --print-stats --progress-bytes --quiet --recover \ - --resume-extract --retry-forever --snaptime \ + --null-output --numeric-owner --one-file-system \ + --passphrase --print-stats --progress-bytes --quiet \ + --recover --resume-extract --retry-forever --snaptime \ --store-atime --strip-components --totals \ --verify-config --version --verylowmem" diff --git a/misc/describe-options.txt b/misc/describe-options.txt index 89d92cd0..24ed0793 100644 --- a/misc/describe-options.txt +++ b/misc/describe-options.txt @@ -65,6 +65,7 @@ --normalmem ignore any lowmem or verylowmem option --nuke delete all of the archives stored MODE --null filenames or patterns are separated by null characters +--null-output filenames in output are separated by null characters --numeric-owner ignore symbolic user and group names when restoring --one-file-system do not cross mount points --passphrase read passphrase from ARG instead of /dev/tty diff --git a/misc/zsh_completion/_tarsnap b/misc/zsh_completion/_tarsnap index 720e0cfe..ea08527d 100644 --- a/misc/zsh_completion/_tarsnap +++ b/misc/zsh_completion/_tarsnap @@ -233,6 +233,7 @@ _shtab_tarsnap__list_archives_options=( "(- : *)"{-h,--help}"[show this help message and exit]" "-f[specify hash of archive name to operate on (requires --hashes)]:tapehash" "--hashes[make --list-archives print hashes]" + "--null-output[filenames in output are separated by null characters]" "-v[produce verbose output]" "--archive-names[read a list of archive names from a file]:filename:{_files}" "--configfile[add file to the list of configuration files to be read]:filename:{_files}" diff --git a/tar/bsdtar.c b/tar/bsdtar.c index 50070f34..240774de 100644 --- a/tar/bsdtar.c +++ b/tar/bsdtar.c @@ -704,6 +704,9 @@ main(int argc, char **argv) case OPTION_NULL: /* GNU tar */ bsdtar->option_null++; break; + case OPTION_NULL_OUTPUT: /* tarsnap */ + bsdtar->option_null_output++; + break; case OPTION_NUMERIC_OWNER: /* GNU tar */ bsdtar->option_numeric_owner++; break; @@ -1026,10 +1029,11 @@ main(int argc, char **argv) only_mode(bsdtar, "--newer-mtime", "cxt"); if (bsdtar->option_absolute_paths) only_mode(bsdtar, "-P", "cxt"); - if (bsdtar->option_null) { - /* Allow in --list-archives or cxt modes. */ + if (bsdtar->option_null) + only_mode(bsdtar, "--null", "cxt"); + if (bsdtar->option_null_output) { if (bsdtar->mode != OPTION_LIST_ARCHIVES) - only_mode(bsdtar, "--null", "cxt"); + only_mode(bsdtar, "--null-output", ""); } /* We should only have remaining args in -c, -t, and -x modes. */ diff --git a/tar/bsdtar.h b/tar/bsdtar.h index 54c7bb67..9b27f5f7 100644 --- a/tar/bsdtar.h +++ b/tar/bsdtar.h @@ -84,6 +84,7 @@ struct bsdtar { char option_no_owner; /* -o */ char option_no_subdirs; /* -n */ char option_null; /* --null */ + char option_null_output; /* --null-output */ char option_numeric_owner; /* --numeric-owner */ char option_print_stats; /* --print-stats */ uint64_t option_progress_bytes; /* --progress-bytes */ @@ -262,6 +263,7 @@ enum { OPTION_NORMALMEM, OPTION_NUKE, OPTION_NULL, + OPTION_NULL_OUTPUT, OPTION_NUMERIC_OWNER, OPTION_ONE_FILE_SYSTEM, OPTION_PASSPHRASE, diff --git a/tar/cmdline.c b/tar/cmdline.c index 47dc5f75..88ba3a22 100644 --- a/tar/cmdline.c +++ b/tar/cmdline.c @@ -152,6 +152,7 @@ static struct option { { "no-totals", 0, OPTION_NO_TOTALS }, { "nuke", 0, OPTION_NUKE }, { "null", 0, OPTION_NULL }, + { "null-output", 0, OPTION_NULL_OUTPUT }, { "numeric-owner", 0, OPTION_NUMERIC_OWNER }, { "one-file-system", 0, OPTION_ONE_FILE_SYSTEM }, { "passphrase", 1, OPTION_PASSPHRASE }, diff --git a/tar/glue/tape.c b/tar/glue/tape.c index 6e177835..01673ba5 100644 --- a/tar/glue/tape.c +++ b/tar/glue/tape.c @@ -191,8 +191,8 @@ tarsnap_mode_list_archives(struct bsdtar *bsdtar, int print_hashes) /* Ask for the list of archives to be printed. */ if (bsdtar->ntapes == 0) { - if (statstape_printlist(d, bsdtar->verbose, bsdtar->option_null, - print_hashes)) + if (statstape_printlist(d, bsdtar->verbose, + bsdtar->option_null_output, print_hashes)) goto err2; } else { /* User wants metadata about specific archive(s). */ @@ -207,7 +207,7 @@ tarsnap_mode_list_archives(struct bsdtar *bsdtar, int print_hashes) /* Print desired metadata about the archive. */ if (statstape_printlist_item(d, hash, - bsdtar->verbose, bsdtar->option_null, 1)) + bsdtar->verbose, bsdtar->option_null_output, 1)) goto err2; } } diff --git a/tar/tarsnap.1-man.in b/tar/tarsnap.1-man.in index 6e9e9ff0..dfbb8cc4 100644 --- a/tar/tarsnap.1-man.in +++ b/tar/tarsnap.1-man.in @@ -112,7 +112,7 @@ line with which was invoked to create each archive is also printed. .PP If the -\fB\--null\fP +\fB\--null-output\fP argument is also specified, each archive name will be separated by a single null character. If the @@ -732,8 +732,8 @@ option specified in a configuration file. (use with \fB\-I\fP, \fB\-T\fP, -\fB\-X\fP, -or list-archives modes only) +or +\fB\-X\fP) Filenames or patterns are separated by null characters, not by newlines. This is often used to read filenames output by the @@ -741,6 +741,10 @@ This is often used to read filenames output by the option to \fBfind\fP(1). .TP +\fB\--null-output\fP +(list-archives mode only) +Filenames in output are separated by null characters, not by newlines. +.TP \fB\--numeric-owner\fP (x mode only) Ignore symbolic user and group names when restoring archives to disk, diff --git a/tar/tarsnap.1-mdoc.in b/tar/tarsnap.1-mdoc.in index 0d760e9b..ee13108a 100644 --- a/tar/tarsnap.1-mdoc.in +++ b/tar/tarsnap.1-mdoc.in @@ -123,7 +123,7 @@ line with which was invoked to create each archive is also printed. .Pp If the -.Fl -null +.Fl -null-output argument is also specified, each archive name will be separated by a single null character. If the @@ -662,14 +662,17 @@ option specified in a configuration file. (use with .Fl I , .Fl T , -.Fl X , -or list-archives modes only) +or +.Fl X ) Filenames or patterns are separated by null characters, not by newlines. This is often used to read filenames output by the .Fl print0 option to .Xr find 1 . +.It Fl -null-output +(list-archives mode only) +Filenames in output are separated by null characters, not by newlines. .It Fl -numeric-owner (x mode only) Ignore symbolic user and group names when restoring archives to disk,