Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --null-output #614

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions misc/bash_completion.d/tarsnap
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 1 addition & 0 deletions misc/describe-options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions misc/zsh_completion/_tarsnap
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
10 changes: 7 additions & 3 deletions tar/bsdtar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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. */
Expand Down
2 changes: 2 additions & 0 deletions tar/bsdtar.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -262,6 +263,7 @@ enum {
OPTION_NORMALMEM,
OPTION_NUKE,
OPTION_NULL,
OPTION_NULL_OUTPUT,
OPTION_NUMERIC_OWNER,
OPTION_ONE_FILE_SYSTEM,
OPTION_PASSPHRASE,
Expand Down
1 change: 1 addition & 0 deletions tar/cmdline.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down
6 changes: 3 additions & 3 deletions tar/glue/tape.c
Original file line number Diff line number Diff line change
Expand Up @@ -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). */
Expand All @@ -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;
}
}
Expand Down
10 changes: 7 additions & 3 deletions tar/tarsnap.1-man.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -732,15 +732,19 @@ 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
\fB\-print0\fP
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,
Expand Down
9 changes: 6 additions & 3 deletions tar/tarsnap.1-mdoc.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down