Pass the arguments alpha, two words, and omega to printf as one word joined by the first character of IFS.
This is not a transfer that preserves separate argument boundaries.
Which expansion is appropriate?
Quoted $* expands all positional arguments as one shell word, joined by the first character of IFS. This differs from quoted $@.
Detailed explanation
$@Incorrect. Unquoted expansion is subject to word splitting and glob expansion.
Incorrect. Unquoted expansion is subject to word splitting and glob expansion.
"$@"Incorrect. Quoted $@ expands each positional argument separately.
Incorrect. Quoted $@ expands each positional argument separately.
"$*"Correct. Quoted $* joins all positional arguments into one word.
Correct. Quoted $* joins all positional arguments into one word.
"$#"Incorrect. Quoted $# expands only the argument count.
Incorrect. Quoted $# expands only the argument count.
Try it yourself
An example you can run in a temporary verification environment.
sh -c 'IFS=,; printf "<%s>\n" "$*"' join alpha 'two words' omegaExpected result
<alpha,two words,omega>Key points
- Quoted $* becomes one argument
- Join using the first IFS character
- Quoted $@ keeps separate arguments
Notes
- Environment: POSIX sh / 短命プロセス
- 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.