This is equivalent to:
( export someVariable=something; command )
This makes someVariable
an environment variable, with the assigned value, but only for the command being run.
Here are the relevant parts of the bash
manual:
Simple Commands
A simple command is a sequence of optional variable assignments followed by blank-separated words and redirections, and terminated by a control operator. The first word specifies the command to be executed, and is passed as argument zero. The remaining words are passed as arguments to the invoked command.
(...)
Simple Command Expansion
If no command name results [from command expansion], the variable assignments affect the current shell environment. Otherwise, the variables are added to the environment of the executed command and do not affect the current shell environment.
Note: bear in mind that this is not specific to bash
, but specified by POSIX.
Edit - Summarized discussion from comments in the answer
The reason BAZ=JAKE echo $BAZ
, doesn't print JAKE is because variable substitution is done before anything else. If you by-pass variable substitution, this behaves as expected:
$ echo_baz() { echo "[$BAZ]"; }
$ BAZ=Jake echo_baz
[Jake]
$ echo_baz
[]