~autumnull/haredo

1

Sharing Variables between .do Files

Details
Message ID
<b00ef7318ab68d457c7947c9bb45ddf3@onemoresuza.mailer.me>
DKIM signature
missing
Download raw message
I've being playing around with `haredo` and being finding it awesome!

I'm trying to find out how to have the .do files share some variables,
e. g., PREFIX, PROGNAME, MANDIR, etc., since the `make` practices are
still ingrained in my head.

Since .do files are run with `sh -e`, one could simply create a, let's
say, `env.sh` file with something like this:

```bash
export PREFIX="${PREFIX:-"/usr/local"}"
export MANDIR="${MANDIR:-"${PREFIX}/share/man"}"
export PROGNAME="${PROGNAME:-"foo"}"
```

and source it in every .do file.

I was wondering the following:

1. Would there be any other way of achieving this variables sharing?
2. Should I be thinking differently on how to work with haredo? Perhaps
   this sharing could be replaced with a more idiomatic construction?
Details
Message ID
<85542ee5-a7ec-47b1-9a87-2f435d0fc3a5@posteo.net>
In-Reply-To
<b00ef7318ab68d457c7947c9bb45ddf3@onemoresuza.mailer.me> (view parent)
DKIM signature
missing
Download raw message
> I've being playing around with `haredo` and being finding it awesome!
Nice, thanks for saying so :)

> I was wondering the following:
> 
> 1. Would there be any other way of achieving this variables sharing?
The way you've listed is the best way I know of. Since the environment 
variables carry down to child processes, you can get away with just 
sourcing env.sh in the .do files that you intend to call as top-level 
targets, but that's the only improvement.

> 2. Should I be thinking differently on how to work with haredo? Perhaps
>     this sharing could be replaced with a more idiomatic construction?
> 
I think you're thinking just fine, I'd say this method is idiomatic, 
although if you find a better way feel free to share it!

~Autumn
Reply to thread Export thread (mbox)