This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the bash category.
Last Updated: 2023-03-28
I encountered the following while working on a Dockerfile entrypoint
set -- php-fpm "$@"
What's going on?
set command - when not used to set options, sets the positional parameters in bash.
# notice how `set` takes multiple arguments $ set foo bar dog $ echo $1 foo $ echo $2 bar $ echo $3 dog
$@ contains all the existing position parameters. Therefore
set -- php-fpm
See for yourself:
$ set foo bar dog $ set -- php-fpm "$@" $ echo $1,$2,$3,$4 php-fpm,foo,bar,dog