Skip to content

tar2rpm: add filename '-' as an alias for stdin and stdout#94

Merged
jarondl merged 1 commit intogoogle:masterfrom
totph:tar2rpm_dash
Oct 21, 2024
Merged

tar2rpm: add filename '-' as an alias for stdin and stdout#94
jarondl merged 1 commit intogoogle:masterfrom
totph:tar2rpm_dash

Conversation

@totph
Copy link
Copy Markdown
Contributor

@totph totph commented Oct 8, 2024

When no filenames are given the informative message
"tar2pm: reading tar content from stdin, writing rpm data to stdout."
is printed to stderr. This can be suppressed by explicitly
specifying '-' for TARFILE and RPMFILE (if only TAR- or RPMFILE is
given the message reflects that).

Also updated usage() to reflect that, and rename FILE to
TARFILE/RPMFILE.

Copy link
Copy Markdown
Contributor

@jarondl jarondl left a comment

Choose a reason for hiding this comment

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

Thanks for the contribution!

I'm not sure I understand the rationale (or indeed the solution). What do you care if some message is printed to stderr? In common practice apps ignore stderr. Can you explain the reasoning?

If this is about some kind of "quietness" or "verbosity", perhaps adding a flag for that would be better than magical behavior difference when you specify "-" or not.

(I'm not saying no to this PR, I just want to understand it better).

@jarondl
Copy link
Copy Markdown
Contributor

jarondl commented Oct 9, 2024

/gcbrun

@totph
Copy link
Copy Markdown
Contributor Author

totph commented Oct 10, 2024

This tries to follow the "silence is golden" rule of most (non-Windows) commandline tools, and - is the common way to specify stdin on the commandline, e.g. cat file1 - file3. Also, tar cv /path | tar2rpm .. prints the list of files, but also the one line from tar2rpm. Otherwise I would only expect stderr output on error, unless explicitly requested.

When no - is specified then printing a notice is helpful, as in "hey, not doing anything because I'm implicitly reading data from stdin (which might be the terminal)". Unlike, say, grep foo which will just sit there.

So, in my opinion no -quiet flag is needed, but I would add a notice to usage(). Or let me know if you would prefer a -quiet or -verbose flag.

@jarondl
Copy link
Copy Markdown
Contributor

jarondl commented Oct 13, 2024

When no - is specified then printing a notice is helpful, as in "hey, not doing anything because I'm implicitly reading data from stdin (which might be the terminal)". Unlike, say, grep foo which will just sit there.

So, in my opinion no -quiet flag is needed, but I would add a notice to usage(). Or let me know if you would prefer a -quiet or -verbose flag.

Sounds good. Please add a notice to usage() saying that passing - explicitly will silence the message.

When no filenames are given the informative message
"tar2pm: reading tar content from stdin, writing rpm data to stdout."
is printed to stderr. This can be suppressed by explicitly
specifying '-' for TARFILE and RPMFILE (if only TAR- or RPMFILE is
given the message reflects that).

Also updated usage() to reflect that, and rename FILE to
TARFILE/RPMFILE.
@totph
Copy link
Copy Markdown
Contributor Author

totph commented Oct 14, 2024

Updated usage, and while writing the text I split the overloaded FILE into TARFILE and RPMFILE, and added the - logic to the output logic as well so it is symmetric. Pardon the slight feature creep :)

@totph totph changed the title tar2rpm: Quietly read from stdin when file '-' is given tar2rpm: add filename '-' as an alias for stdin and stdout Oct 14, 2024
@jarondl jarondl merged commit 8407d9a into google:master Oct 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants