In the current interactive Bash, make gs expand to git status.
Pass the replacement containing a space as one alias definition.
Which command is appropriate?
Quote an alias replacement containing spaces so NAME=value is passed as one argument. The command is not executed while the alias is defined.
Detailed explanation
alias gs=git statusIncorrect. status becomes a separate argument instead of part of the replacement.
Incorrect. status becomes a separate argument instead of part of the replacement.
alias gs='git status'Correct. Quoting keeps git status together as the alias replacement.
Correct. Quoting keeps git status together as the alias replacement.
alias 'gs=git' statusIncorrect. It does not define the requested replacement.
Incorrect. It does not define the requested replacement.
alias gs $(git status)Incorrect. It executes git status while defining the alias.
Incorrect. It executes git status while defining the alias.
Try it yourself
An example you can run in a temporary verification environment.
bash --noprofile --norc -ic "alias gs='printf alias-quoted\\n'; alias gs"Expected result
gsのalias定義を表示Key points
- Quote values containing spaces
- Definition does not execute the command
- Use alias NAME=value
Notes
- Environment: GNU Bash 5.2 / 一時対話シェル
- 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.