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

Proposal: Mark cat file.txt | or < file.txt as preferred in the style guide #13668

Open
Managor opened this issue Sep 11, 2024 · 2 comments
Open

Comments

@Managor
Copy link
Collaborator

Managor commented Sep 11, 2024

cat file.txt | and < file.txt do the same exact thing. For this reason it would be beneficial to prefer using one over the other in the pages. The advantage of < file.txt would be that we don't need to involve any other commands but it's less known than piping. Thus new users might not understand what it does. If we started using it commonly, the knowledge of what it does might spread. cat file.txt | has the advantage that everyone has seen it being used.

This should not be a hardline stance. Each command should be judged case by case based on how it's most commonly written on the internet, but when in doubt this guideline could be used.

@Managor Managor changed the title Proposal: Prefer either cat file.txt | or < file.txt in the style guide Proposal: Mark cat file.txt | or < file.txt as preferred in the style guide Sep 11, 2024
@jxu
Copy link
Collaborator

jxu commented Nov 17, 2024

The "useless use of cat" IMO is only to show you can pipe stuff in while < file.txt looks a little awkward not flowing left-to-right. Many (but not all) programs, e.g. jq can read input from file natively, but maybe it is more useful in a pipeline, e.g. from the output of curl.

@Managor
Copy link
Collaborator Author

Managor commented Nov 17, 2024

The command flowing from left to right is a very strong argument. < file.txt is not technically part of the command and thus disrupts it.

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

No branches or pull requests

2 participants