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

Merged
merged 3 commits into from
Jan 12, 2025
Merged

Add --null-output #614

merged 3 commits into from
Jan 12, 2025

Conversation

gperciva
Copy link
Member

No description provided.

@gperciva
Copy link
Member Author

The --null option was previously used for reading input with -T or -X. When we extended it to apply to --list-archives as well, we were using it to modify the output behaviour.

That wasn't ideal, but we could have lived with it, because there isn't any input to --list-archives.

However, consider the situation if we want NUL-separated output for -tvf. If we used --null for that, then if the user wanted to use -T it would force them to write that file with NUL bytes instead of newlines.

Adding --null-output allows the user to have different separators for the input and output. (We can think of "--null" as "--null-input", but we're not renaming it for historical / bsdtar-compatibility reasons.)

(Yes, if the user wanted newlines in output but NUL in input, they could do | sed -s 's/\x0/\n/g' but that's an awkward solution.)

@gperciva
Copy link
Member Author

We allowed --null in --list-archives in #576, which was after tarsnap 1.0.40. It has not been part of a stable release, so I don't think it's a problem to change that to --null-output.

@gperciva gperciva marked this pull request as draft November 20, 2024 23:10
@gperciva gperciva marked this pull request as ready for review November 21, 2024 02:16
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/Filenames/Archive names/ ?

@@ -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]"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/filenames/archive names/ ?

@gperciva
Copy link
Member Author

Fixed because it's true that as of this PR, --null-output can only apply to archive names.

A later PR will extend that to filenames as well, but we'll change the man page at that time.

@cperciva
Copy link
Member

Right, I knew --null-output was coming to -t later but I wanted to keep the history clear.

Please clean up the commits and then I'll merge.

This should have been part of:
    2023-08-30 Allow --list-archives --null
    d21dff3

The --null option was previously used for reading input with -T or -X.
When we extended it to apply to --list-archives as well, we were using
it to modify the *output* behaviour.

That wasn't ideal, but we could have lived with it, because there isn't
any input to --list-archives.  But suppose that we wanted to allow -T
with --list-archives --hashes (i.e. provide a filename which contains
hashes which we want to print)?  The user would be stuck with either
having NUL-separated both input and output, or having newlines for both.

Adding --null-output allows the user to have different separators for
the input and output.  (We can think of "--null" as "--null-input", but
we're not renaming "--null" for historical / bsdtar-compatibility reasons.)
These changes were made automatically via scripts.
@gperciva
Copy link
Member Author

Rebased, ready for merge.

@cperciva cperciva merged commit 4714983 into master Jan 12, 2025
2 checks passed
@gperciva gperciva deleted the null-output branch January 12, 2025 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants