docker-library / rabbitmq

Docker Official Image packaging for RabbitMQ
http://www.rabbitmq.com/
MIT License
785 stars 417 forks source link

Only first entry of BASH_SOURCE array used in Docker entrypoint script #730

Closed grmhskidata closed 2 months ago

grmhskidata commented 2 months ago

In the Docker entrypoint script, the $BASH_SOURCE variable is referenced: https://github.com/docker-library/rabbitmq/blob/444c58b5b51433019a9422737ee98b05adcf7e06/4.0/alpine/docker-entrypoint.sh#L10

According to the documentation (https://www.gnu.org/software/bash/manual/html_node/Bash-Variables.html#index-BASH_005fSOURCE), BASH_SOURCE is an array, and expanding an array without an index only gives the first element, see https://www.shellcheck.net/wiki/SC2128. Depending on what is desired for that command, the expansion of BASH_SOURCE should be improved to either reference the first element (i.e., ${BASH_SOURCE[0]}) or to expand the entire array (i.e., ${BASH_SOURCE[@]}).

tianon commented 2 months ago

The intention is the first element (this is intentional). Thanks for checking, though!

grmhskidata commented 2 months ago

But in that case, "${BASH_SOURCE[0]}" would make the intention clear and avoid possible confusion.