zsh: unknown file attribute
34,675
Accoring to this article, *
and @
both contain an array of the positional parameters.
The parameters
*
,@
andargv
are arrays containing all the positional parameters; thus$argv[n]
, etc., is equivalent to simply$n
.
And...
A subscript of the form
[*]
or[@]
evaluates to all elements of an array; there is no difference between the two except when they appear within double quotes."$foo[*]"
evaluates to"$foo[1] $foo[2] ..."
, whereas"$foo[@]"
evaluates to"$foo[1]" "$foo[2]" ...
.
Author by
Marcel
Updated on May 17, 2020Comments
-
Marcel almost 4 years
I have the following function in my
.zshrc
which, in theory, allows me to write a commit message without needing quotation marks.cm(){ git commit -m "$@" }
When I run it (
cm foo bar
), I get the following error:zsh: unknown file attribute
Does
$@
mean the same thing in zsh as it does in bash? -
Marcel almost 8 yearsThat seems to work now with ${} instead of $. I wonder why zsh would implement this differently.
-
Adam Lee almost 8 yearsYou mean that you substituted "$@" in your code with "${@}"?
-
Marcel almost 8 yearsNo sorry that was confusing. I substituted
"$@"
with"${*}"
. I put the wrong thing in my comment because that's what I started with. I just switched $* to $@ when I was troubleshooting. As I understand it, $@ is like an array and $* is a space-separated string.