2015-05-15 145 views
4

我無法將shell腳本轉換爲zsh。我定義了以下數組,但它拋出了錯誤unknown file attribute: \n。 (我是一個點文件轉換回購我的zsh)在ZSH中聲明數組

declare -r -a FILES_TO_SOURCE=(
    "bash_aliases" 
    "bash_exports" 
    "bash_functions" 
    "bash_options" 
    "bash_prompt" 
    "bash.local" 
) 

回答

3

man zshbuiltins,進入下typeset(其中declare的代名詞):

對於每個名稱=值分配,參數名稱設置爲。請注意,當前不能將 指定爲排版表達式,只有標量和整數。

試試這個:

declare -a FILES_TO_SOURCE 
FILES_TO_SOURCE=(
    "bash_aliases" 
    "bash_exports" 
    "bash_functions" 
    "bash_options" 
    "bash_prompt" 
    "bash.local" 
) 
declare -r FILES_TO_SOURCE 

話雖這麼說,文件列表將不得不在這裏也最有可能更改兼容性(假設你已經使用的bash-主義在這似乎這些文件可能)。