Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Globbing directories

8 views
Skip to first unread message

Sean Russell

unread,
Nov 9, 2024, 9:49:45 AM11/9/24
to tup-users
Hi

I seem to be hitting all of the things at once. Note that this isn't about recursive globbing.

Should this rule work?

   : foreach a/*/x.txt |> (more rule stuff)

It isn't, for me. E.g.

   mkdir -p test/a/b test/a/c
   cd test
   touch a/b/x.txt a/c/x.txt
   tup init
   echo ': foreach a/*/x.txt |> touch %o |> %g' > Tupfile
   tup

I'd expect b and c to be created; instead, I get the error:

   Failed to f ind directory ID for dir a/*/x.txt' relative to '.'
 
Thanks

Guillaume @layus Maudoux

unread,
Nov 9, 2024, 11:00:31 AM11/9/24
to tup-...@googlegroups.com
Sadly no, it is not supposed to work. Quoting the manual:

Wildcarding is supported within a directory by using the SQLite glob function. The special glob characters are '*', '?', and '[]'. For example, "*.c" would match any .c file, "fo?.c" would match any 3-character .c file that has 'f' and 'o' as the first two characters, and "fo[xyz].c" would match fox.c, foy.c, and foz.c. Globbing does not match directories, so "src/*.c" will work, but "*/*.c" will not.

Sean Russell

unread,
Nov 13, 2024, 11:03:33 AM11/13/24
to tup-users
Oh, shoot. I missed

> Globbing does not match directories

Is there a work-around? How are other people doing this sort of thing?

Guillaume @layus Maudoux

unread,
Nov 13, 2024, 2:01:31 PM11/13/24
to Sean Russell, tup-users
There are many ways to make it work, but maybe very specific.

Proceed level by level, creating Tupfiles in the subfolders.

You may want to consider `run ./script args`.

But there will probably never be anything like a recursive folder glob à la `**/*.json`.

Guillaume @layus Maudoux

unread,
Nov 13, 2024, 2:07:13 PM11/13/24
to Sean Russell, tup-users
Depending on your use-case <group>s and {bin}s can also be used.

But as you will see, groups are not top down, they are bottom up. Subrules add their outputs to a group. A group is not described by a top-level glob pattern.

Macros and groups can be powerful in some cases.
Reply all
Reply to author
Forward
0 new messages