I need to run a parallel for loop in posix shell (not bash). But it is currently not executing in docker and skipping that statement on adding &
to the for loop.
Reference question with details: Shell script not running as bash using Dockerfile
Code snippet from reference question:
if [ -z "$GWC_PC_ID" ]
then
ENV_NAME=$ENV_NAME RUN_OPTIONS=$SCENARIO_NAME-$ENV_NAME$OPTIONS_VARIANT k6 run $K6_RUN_OPTIONS ''$SCENARIO/index.js''
else
for pcId in $(printf '%s' "$GWC_PC_ID" | tr , ' ');
do
ENV_NAME=$ENV_NAME RUN_OPTIONS=$SCENARIO_NAME-$ENV_NAME$OPTIONS_VARIANT GWC_PC_ID=$pcId k6 run $K6_RUN_OPTIONS ''$SCENARIO/index.js'' &
done
fi
Here if I give empty input, it runs fine but for non-empty input, it does not execute statement inside for loop. Note that if I remove &
then it executes the statement inside for loop but I need to run those statements parallely.