tup icon indicating copy to clipboard operation
tup copied to clipboard

Foreach doesn't work with groups.

Open p2rkw opened this issue 11 years ago • 4 comments

Hello, It seems that groups aren't expanded in rule input, so rules like: : foreach %<group> |> mv %f %o |> %B and : foreach <group> |> mv %f %o |> %B doesn't work.

(I'm trying to workaround issue #220 )

Greetings.

Edit: It works for {bins}.

p2rkw avatar Feb 08 '15 23:02 p2rkw

You don't need foreach. You also have to expand the group using %<group> instead of %f inside the command.

Try:

: <group> |> mv %<group> %o |> %B 

See the %<group> section of the manual: http://gittup.org/tup/manual.html

kavika13 avatar Aug 05 '16 15:08 kavika13

As I understand, this doesn't actually solve the OP's problem though, does it? It appears they want to do:

mv foo.c foo
mv bar.c bar
mv baz.c baz

The rule suggested by @kavika13 wouldn't even compile, because tup expands the %<group> in place, trying to create something like mv foo.c bar.c baz.c .... As a result, %B won't work at all because the input is a list of files, therefore %o won't expand either and tup will complain.

shaneleonard avatar Aug 27 '16 18:08 shaneleonard

Using {bin} is also a limited solution because it only works for the current directory. What if you want to individually operate on the members of this group in a parent directory rather than in place?

shaneleonard avatar Aug 27 '16 18:08 shaneleonard

Yep, my bad. For the mv command, that type of group expansion would not work.

kavika13 avatar Sep 08 '16 19:09 kavika13