One problem with this approach is if I add a new file to a subfolder, tup 
doesn't see it and know to automatically re-run the shell script :-( Any 
ideas how I could fix that?

On Wednesday, March 14, 2018 at 10:20:06 PM UTC, Ben Golightly wrote:
>
>
> Hi, apologies if this has been asked before. I searched but didn't find 
> anything.
>
> I have a rule that I want to apply to everything in a directory, and again 
> in all subdirectories (possibly again, recursively, in all subdirectories 
> of that), with the output destination mirroring this.
>
> For example, my first attempt might look like this:
>
> : foreach src/*.input         |> dothing %f %o |> dest/%B.output
> : foreach src/foo/*.input     |> dothing %f %o |> dest/foo/%B.output
> : foreach src/foo/bar/*.input |> dothing %f %o |> dest/foo/bar/%B.output
> : foreach src/bar/*.input     |> dothing %f %o |> dest/bar/%B.output
>
> The commands "run ./script args" and "preload directory" described in the 
> manual let me do this with a separate shell script.
>
> Here's what I came up with:
>
> *Tupfile:*
> preload src/pages
> run ./mkpage.inc.sh
>
> *mkpage.inc.sh <http://mkpage.inc.sh>*
> #! /bin/sh -e
>
> cmd ()
> {
>     echo ": foreach src/$1*.input |> dothing %f %o |> dest/$1%B.output"
> }
>
> cd "src"
> dirs="."/*
>
> cmd
>
> for entry in $dirs
> do
>     if [ -d "$entry" ];then
>         cmd $entry
>     fi
> done
> cd "../"
>
>
> This works for me (with a bit of work I could make it recursive).
>
> I hope someone else might find it useful.
>
> But I was also wondering if there was a better way to do this natively 
> with tup?
>
> Thanks
>
> Ben
>
>
>

-- 
-- 
tup-users mailing list
email: [email protected]
unsubscribe: [email protected]
options: http://groups.google.com/group/tup-users?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"tup-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to