From 8c5d13fe0e8af6f38eb632de9321fda9db32ca1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Fri, 15 Sep 2023 09:14:09 +0200 Subject: [PATCH] Add note to documentation about shell expansion --- docs/jobs/arrays.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/jobs/arrays.md b/docs/jobs/arrays.md index ae843e35a..d4024ef62 100644 --- a/docs/jobs/arrays.md +++ b/docs/jobs/arrays.md @@ -59,6 +59,21 @@ contain each filepath on a separate line and then pass it to the submit command $ hq submit --each-line entries.txt ... ``` +!!! tip + To directly use an environment variable in the submitted command, you have to make sure that it will be expanded + when the command is executed, not when the command is submitted. You should also execute the command in a bash script + if you want to specify it directly and not via a script file. + + For example, the following command is **incorrect**, as it will expand `HQ_ENTRY` during submission (probably to an + empty string) and submit a command `ls `: + ```bash + $ hq submit --each-line files.txt ls $HQ_ENTRY + ``` + To actually submit the command `ls $HQ_ENTRY`, you can e.g. wrap the command in apostrophes and run it in a shell: + ```bash + $ hq submit --each-line files.txt bash -c 'ls $HQ_ENTRY' + ``` + ### JSON array You can also specify the source using a JSON array stored inside a file. HyperQueue will then create a task for each item in the array and pass the item as a JSON string to the corresponding task using the environment variable `HQ_ENTRY`.