Description
The code snippet under “The faster way” in the Catalog image resizing documentation contains invalid bash syntax and fails with a parse error.
Doc page: https://experienceleague.adobe.com/en/docs/commerce-operations/implementation-playbook/best-practices/development/catalog-image-resizing#the-faster-way
Current snippet (as published):
for i in {1.."$((2 * `nproc --all`))"};do bin/magento queue:consumers:start media.storage.catalog.image.resize &;done;
When executed in bash, it errors:
bash: syntax error near unexpected token `;'
Steps to reproduce
- Open the doc page linked above and copy the snippet from the “The faster way” section
- Paste it into a bash shell on a machine with nproc available (Linux) and Magento’s bin/magento present
- Run the command
Expected result
The snippet should be valid bash and start (2 * number_of_CPUs) consumer processes for media.storage.catalog.image.resize without a syntax error.
Possible solutions
Replace the snippet with a valid loop. For example:
for i in $(seq 1 "$((2 * $(nproc --all)))"); do
bin/magento queue:consumers:start media.storage.catalog.image.resize &
done
This uses seq for the range and uses $(...) command substitution consistently.
Additional information
The current snippet mixes brace expansion with a quoted arithmetic expansion (and backticks) in a way that doesn’t form a valid list for for i in ....
Tested in bash; the published one-liner fails to parse before it can run any Magento commands.
Description
The code snippet under “The faster way” in the Catalog image resizing documentation contains invalid bash syntax and fails with a parse error.
Doc page: https://experienceleague.adobe.com/en/docs/commerce-operations/implementation-playbook/best-practices/development/catalog-image-resizing#the-faster-way
Current snippet (as published):
When executed in bash, it errors:
Steps to reproduce
Expected result
The snippet should be valid bash and start (2 * number_of_CPUs) consumer processes for
media.storage.catalog.image.resizewithout a syntax error.Possible solutions
Replace the snippet with a valid loop. For example:
This uses seq for the range and uses $(...) command substitution consistently.
Additional information
The current snippet mixes brace expansion with a quoted arithmetic expansion (and backticks) in a way that doesn’t form a valid list for for i in ....
Tested in bash; the published one-liner fails to parse before it can run any Magento commands.