Good Afternoon,
In a cylc workflow I am trying to set an environment parameter with a bash array, like this:
[task parameters]
client_number = 0, 1
[ runtime ]
[[client_name<client_number>]]
script = client_name.sh
[[[environment]]]
names_arr = ('Mark' 'Antony')
client_name = ${names_arr[${CYLC_TASK_PARAM_client_number}]}
So that in the script I would have automathically the client name set (Mark, for client zero, and Antony for client one).
But this is not working, since when exported in the job the environment variables get wrapped in quotes, and so in I get
client_name="('Mark' 'Antony')"
Which is not a bash array, and my strategy does not work anymore.
I tried a different approach, with no better success.
I define an array in a json file:
[
{
"names" : ["Mark", "Antony"]
}
]
And in the workflow
{% set clients = load_json('env/clients.json') %}
{% for client in client %}
[task parameters]
client_number = 0, 1
[ runtime ]
[[client_name<client_number>]]
script = client_name.sh
[[[environment]]]
client_name = {{client['names'][${CYLC_TASK_PARAM_client_number}]}}
But it throws a Template Syntax error.
I tryed also the syntax %(client_number)d, or <client_number>, with no better luck.
(It works though if I hardcode 0 or 1:
{{client['names'][0]}}
).
Any suggestion on how to better manage this?
Many thanks in advance,
Stella