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.
$DEPLOY_ENV=stagingIncorrect. $DEPLOY_ENV is an expansion, not a valid assignment name.
DEPLOY_ENV=stagingCorrect. DEPLOY_ENV=staging assigns the value in the current shell.
set DEPLOY_ENV stagingIncorrect. 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 / シェル変数のみ
- Use disposable shell sessions and harmless commands for experiments.
- Shell behavior can depend on Bash options and distribution defaults.
Foundation review
Place the operation
A shell assignment names the variable on the left; a dollar sign is used when reading it.
Check the side effect
Quote the value when it contains spaces and inspect it with printf or a shell query.