2016-05-13 237 views
3

我在我的.zshrc中有以下功能,理論上它允許我寫入提交消息而不需要引號。zsh:未知文件屬性

cm(){ 
    git commit -m "[email protected]" 
} 

當我運行它(cm foo bar),我收到以下錯誤:

zsh: unknown file attribute 

是否[email protected]意味着zsh的同樣的事情,因爲它在bash呢?

回答

1

認可爲this文章,*@都包含位置參數數組。

The parameters * , @ and argv are arrays containing all the positional parameters; thus $argv[n] , etc., is equivalent to simply $n .

而且......

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]" ... .

+0

這似乎現在$ {*}而不是$工作*。我想知道爲什麼zsh會以不同的方式實現。 – Marcel

+0

你的意思是你在代碼中用「$ {@}」代替了「$ @」? –

+0

沒有抱歉,這是令人困惑。我用'「$ {*}」替換''$ @「''。我在我的評論中寫了錯誤的東西,因爲那是我開始的。當我排除故障時,我只是將$ *換成$ @。據我瞭解,$ @就像一個數組,$ *是一個空格分隔的字符串。 – Marcel