Assign staging to DEPLOY_ENV in the current Bash without trying to execute staging as a command.
Which assignment is correct?
Bash assignments use NAME=value with no spaces. The $ prefix is used when referring to a variable.
Detailed explanation
DEPLOY_ENV = stagingIncorrect. Spaces make Bash parse DEPLOY_ENV as a command or argument rather than an assignment.
Incorrect. Spaces make Bash parse DEPLOY_ENV as a command or argument rather than an assignment.
$DEPLOY_ENV=stagingIncorrect. $DEPLOY_ENV is an expansion, not a valid assignment name.
Incorrect. $DEPLOY_ENV is an expansion, not a valid assignment name.
DEPLOY_ENV=stagingCorrect. DEPLOY_ENV=staging assigns the value in the current shell.
Correct. DEPLOY_ENV=staging assigns the value in the current shell.
set DEPLOY_ENV stagingIncorrect. set is not the normal Bash assignment syntax.
Incorrect. set is not the normal Bash assignment syntax.
Try it yourself
An example you can run in a temporary verification environment.
DEPLOY_ENV=staging; printf '%s\n' "$DEPLOY_ENV"Expected result
stagingKey points
- No spaces in assignment
- No $ on the left side
- Use $NAME when expanding
Notes
- Environment: Bash 5.x / シェル変数のみ
- Command output formatting can vary slightly by distribution or tool version.
- Run the example in a temporary directory or process when possible.
Foundation review
Read the scope first
Check whether the command acts on the current shell, a new process, an existing process, or a file.
Verify the observable result
Use the supplied command and compare the output with the expected result.