git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Martin Langhoff <martin.langhoff@gmail.com>
Date
Jun 6, 2007, 03:58 UTC
Message-ID
<46a038f90706052058h1c823278o78ce0d8edce3caab@mail.gmail.com>
In-Reply-To
<87sl957naf.fsf@graviton.dyn.troilus.org>
On 6/6/07, Michael Poole <mdpoole@troilus.org> wrote:
Show 14 quoted lines
> Stephen Rothwell writes:
>
> > On Tue, 05 Jun 2007 18:34:59 -0700 Josh Triplett <josh@freedesktop.org> wrote:
> >>
> >> -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
Previous: Michael PooleNext: Stephen Rothwell
Message 4 of 6 in “Remove useless uses of cat, and replace with filename arguments or redirection”
  1. Remove useless uses of cat, and replace with filename arguments or redirectionJosh Triplett, Jun 6, 2007
  2. Stephen RothwellJun 6, 2007
  3. Michael PooleJun 6, 2007
  4. Martin LanghoffJun 6, 2007
  5. Stephen RothwellJun 6, 2007
  6. Martin LanghoffJun 6, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.