'Hysterical Raisins', aka Historical Reasons.
The explanation from JesperE (or the Bash man page on shell parameter expansion) is accurate for what it does:
- If
$1
exists and is not an empty string, then substitute the quoted list of arguments.
Once upon 20 or so years ago, some broken minor variants of the Bourne Shell substituted an empty string ""
for "$@"
if there were no arguments, instead of the correct, current behaviour of substituting nothing. Whether any such systems are still in use is open to debate.
[Hmm: that expansion would not work correctly for:
command '' arg2 arg3 ...
In this context, the correct notation is:
${1+"$@"}
This works correctly whether $1
is an empty argument or not. So, someone remembered the notation incorrectly, accidentally introducing a bug.]
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…