8000 Count from stdin by faho · Pull Request #5744 · fish-shell/fish-shell · GitHub
[go: up one dir, main page]

Skip to content

Count from stdin#5744

Merged
faho merged 3 commits intofish-shell:masterfrom
faho:count-stdin
Mar 15, 2019
Merged

Count from stdin#5744
faho merged 3 commits intofish-shell:masterfrom
faho:count-stdin

Conversation

@faho
Copy link
Member
@faho faho commented Mar 14, 2019

Description

This allows our count builtin to also count lines fed from stdin.

  • Like string, it will only do so when it's directly redirected.

  • It will still count the arguments and add them together.

  • It will count newlines, so echo -n results in 0. This is also what wc -l does.

This removes uses of wc -l, which in some versions indents its output, which makes it annoying to work with.

TODOs:

  • Changes to fish usage are reflected in user documentation/manpages.
  • Tests have been added for regressions fixed
  • User-visible changes noted in CHANGELOG.md

faho added 2 commits March 14, 2019 20:26
As a simple replacement for `wc -l`.

This counts both lines on stdin _and_ arguments.

So if "file" has three lines, then `count a b c < file` will print 6.

And since it counts newlines, like wc, `echo -n foo | count` prints 0.
Removes any uses of `wc` in our codebase.
@faho faho added this to the fish 3.1.0 milestone Mar 14, 2019
@faho faho merged commit b3f3909 into fish-shell:master Mar 15, 2019
@floam
Copy link
Member
floam commented Mar 16, 2019

I think we can diverge from wc -l on printf foo | count.

@faho faho deleted the count-stdin branch April 1, 2019 14:07
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0