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

git-effort: replace "wc | cut" with "wc | awk" #370

Merged
merged 1 commit into from
May 13, 2015
Merged

Conversation

ihoro
Copy link
Contributor

@ihoro ihoro commented May 11, 2015

It looks "cut" may have different behaviour, e.g. BSD one works the way
git-effort doesn't expect. "awk" looks to be one of possible fixes here.

It looks "cut" may have different behaviour, e.g. BSD one works the way
git-effort doesn't expect. "awk" looks to be one of possible fixes here.
@ihoro
Copy link
Contributor Author

ihoro commented May 11, 2015

A little example to give an idea:

$ wc -l bin/git-effort
     145 bin/git-effort
$ wc -l bin/git-effort | cut -d' ' -f1

$ wc -l bin/git-effort | cut -d' ' -f6
145
$ wc -l bin/git-effort | awk '{print $1}'
145

@ihoro
Copy link
Contributor Author

ihoro commented May 11, 2015

I've checked the same with GNU coreutils:

$ wc -l bin/git-effort
145 bin/git-effort
$ wc -l bin/git-effort | cut -d' ' -f1
145
$ wc -l bin/git-effort | awk '{print $1}'
145

So, "wc" looks to be "the one", i.e. behavior diff between GNU & BSD ones.

@hemanth
Copy link
Collaborator

hemanth commented May 12, 2015

Finally, awk helps ?

@chernjie
Copy link
Contributor

Perhaps we could consider using stdin, it produce consistent result across GNU and BSD, and it does not depend on cut or awk

$ wc -l < bin/git-effort
145

@ihoro
Copy link
Contributor Author

ihoro commented May 12, 2015

@chernjie: unfortunately, it still prefixes it with a tab:

$ wc -l < bin/git-effort
     145

@hemanth: yes, "awk" still helps.

@hemanth
Copy link
Collaborator

hemanth commented May 12, 2015

Let's merge this rather than fixing wc?

@ihoro
Copy link
Contributor Author

ihoro commented May 12, 2015

@hemanth: yep, there's nothing to do with "wc" itself, it differs from system to system.

hemanth added a commit that referenced this pull request May 13, 2015
git-effort: replace "wc | cut" with "wc | awk"
@hemanth hemanth merged commit 9b45e6b into tj:master May 13, 2015
@hemanth
Copy link
Collaborator

hemanth commented May 13, 2015

Thanks @phigoro 👍

@qw3rtman qw3rtman mentioned this pull request Dec 27, 2015
tardypad pushed a commit to tardypad/git-extras that referenced this pull request Jul 13, 2016
git-effort: replace "wc | cut" with "wc | awk"
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.

4 participants