[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Using svn in a unix pipe

From: Gareth McCaughan <gareth.mccaughan_at_pobox.com>
Date: 2006-05-03 01:23:47 CEST

On Tuesday 02 May 2006 21:28, Garrett Rooney wrote:
> On 5/2/06, Steven Elliott <steven.s.elliott@gmail.com> wrote:
...
> > What I am trying to do is take the output of "svn st" and pipe that back
> > into "svn add" or "svn del" or...
> >
> > I have so far got
> >
> > svn st | egrep "\?" | sed 's/\?\(.*\)/ \1/' | svn add
> >
> > So svn is outputting to egrep which is taking all the files marked "?"
> > and sending that to sed to strip off the "?" (which could be "!" ..etc)
> > which I would then like to send to svn add (or delete or...).
> >
> > Problem is the stdout is not making it to the add argument.
> >
> > Any help would be appreciated.
>
> I suspect your sed command isn't working, if you drop the | svn add
> off the end you'll see that there just isn't any output at that point.
>
> Note that I do something very similar with awk all the time:
>
> svn st | grep ^\? | awk '{ print $2 }' | xargs svn add
>
> And it works just fine (assuming there aren't any spaces in your
> filenames anyway).

The "xargs" was missing in Steven's original pipeline.
But be careful, Steven (and others who may be reading),
because xargs may split your list up and invoke "svn add"
multiple times. Check "man xargs" on your system to see
whether you need to be scared; on mine it'll start splitting
once the command line gets beyond 5k bytes.

If there's any danger that you'll need more than that,
you want "svn add --targets". Unfortunately, that seems
to require a genuine filename:

    $ svn add --targets -
    svn: Reading from stdin is currently broken, so disabled

so you can't use a pipeline as such any more. Then again,
with a list that long you might be glad of a record of
just what you fed to "svn add" anyway.

-- 
g
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Wed May 3 01:25:18 2006

This is an archived mail posted to the Subversion Users mailing list.