joerdav / xc

Markdown defined task runner.
https://xcfile.dev/
MIT License
1.04k stars 25 forks source link

Q: Use shell environment variables in the xc Env variable? #118

Closed toddbrooks closed 5 days ago

toddbrooks commented 3 weeks ago

Assumption: Usage of direnv and have a .envrc file with the following exports:

export ETLROOT='/Users/foo/data'
export ETLDATE='2024-06-19'

A README.md Markdown task runner file with the following:

## Tasks

### test-task
Env: WORKING_DIR=$ETLROOT/$ETLDATE
\```bash
echo $WORKING_DIR
\```

(added backslash before the backticks only for visibility in this post)

Expectation: $ /Users/foo/data/2024-06-19

Is it possible to combine the use of shell environment variables with the xc Env: / environment: variables for task usage? Or am I missing something obvious with how I'm using both?

joerdav commented 1 week ago

One option you have would be to do the concatenation within your script:

## Tasks

### test-task

Inputs: ETLROOT, ETLDATE

```bash
export WORKING_DIR=$ETLROOT/$ETLDATE
echo $WORKING_DIR
toddbrooks commented 5 days ago

Thank you, @joerdav ! Sorry for late reply...hurricane Beryl had other plans.