Re: [PATCH] Remove useless uses of cat, and replace with filename arguments or redirection

4 messages, 3 authors, 2016-06-15 · open the first message on its own page

Re: [PATCH] Remove useless uses of cat, and replace with filename arguments or redirection

From: Michael Poole <hidden>
Date: 2016-06-15 22:43:14

Stephen Rothwell writes:
On Tue, 05 Jun 2007 18:34:59 -0700 Josh Triplett [off-list ref] wrote:
quoted
-commits=$(cat ../revs | wc -l | tr -d " ")
+commits=$(wc -l ../revs | tr -d " ")
This is not equivalent, you probably wanted:

commits=$(wc -l <../revs | tr -d " ")
Which relevant version(s) of wc do not accept filename arguments?
POSIX[1] seems to specify it.  Or do you mean that there is some
subtle difference in its processing of stdin vs specified files?

[1]- http://www.opengroup.org/onlinepubs/000095399/utilities/wc.html

Michael Poole

Re: [PATCH] Remove useless uses of cat, and replace with filename arguments or redirection

From: Martin Langhoff <hidden>
Date: 2016-06-15 22:43:14

On 6/6/07, Michael Poole [off-list ref] wrote:
Stephen Rothwell writes:
quoted
On Tue, 05 Jun 2007 18:34:59 -0700 Josh Triplett [off-list ref] wrote:
quoted
-commits=$(cat ../revs | wc -l | tr -d " ")
+commits=$(wc -l ../revs | tr -d " ")
This is not equivalent, you probably wanted:

commits=$(wc -l <../revs | tr -d " ")
Which relevant version(s) of wc do not accept filename arguments?
POSIX[1] seems to specify it.  Or do you mean that there is some
subtle difference in its processing of stdin vs specified files?
Josh is right. The output *is* different because it contains the
filename as well. See

  $ wc < .gitk | tr -d " "
  2177551
  $ wc .gitk | tr -d " "
  2177551.gitk

cheers


m

Re: [PATCH] Remove useless uses of cat, and replace with filename arguments or redirection

From: Stephen Rothwell <hidden>
Date: 2016-06-15 22:43:14

On Wed, 6 Jun 2007 15:58:09 +1200 "Martin Langhoff" [off-list ref] wrote:
Josh is right. The output *is* different because it contains the
  ^^^^
My name is Stephen  :-) and that is indeed what I meant.

Cheers,
Stephen Rothwell

Re: [PATCH] Remove useless uses of cat, and replace with filename arguments or redirection

From: Martin Langhoff <hidden>
Date: 2016-06-15 22:43:14

On 6/6/07, Stephen Rothwell [off-list ref] wrote:
On Wed, 6 Jun 2007 15:58:09 +1200 "Martin Langhoff" [off-list ref] wrote:
quoted
Josh is right. The output *is* different because it contains the
  ^^^^
My name is Stephen  :-) and that is indeed what I meant.
Sorry! Cross-eyed over the email thread, but not over posix behaviour ;-)

...cleans those glasses now


martin
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help