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. Quoted $@ expands each positional argument separately.
"$*"Correct. Quoted $* joins all positional arguments into one word.
"$#"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
Shell function
A reusable group of commands that runs in the caller's shell context.
Positional parameter
A numbered argument or special value supplied to a script or function.
Control flow
Conditions, loops, and exit statuses determine which shell commands run.