0

端末に悪いパターンの出力が表示されます:

   ➜  ~  source .bash_profile
load_dotfiles:1: bad pattern: files=(\n        /Users/xeLL/.rvm/scripts/rvm # Load RVM into a shell session *as a function*\n        /Users/xeLL/.dotfiles/shell/bash_options # Options\n        /Users/xeLL/.dotfiles/shell/bash_exports # Exports\n        /Users/xeLL/.dotfiles/shell/bash_aliases # Aliases\n        /Users/xeLL/.dotfiles/shell/functions/* # Functions\n        /Users/xeLL/.dotfiles/shell/bash_prompt # Custom bash prompt\n        /Users/xeLL/.dotfiles/shell/bash_paths # Path modifications\n        /usr/local/etc/bash_completion # Bash completion (installed via Homebrew)\n        /Users/xeLL/.bash_profile.local # Local and private settings not under version control (e.g. git credentials)\n    )
   ➜  ~

これは bash_profile の一部です:

load_dotfiles() {
declare -a files=(
    $HOME/.rvm/scripts/rvm # Load RVM into a shell session *as a function*
    $HOME/.dotfiles/shell/bash_options # Options
    $HOME/.dotfiles/shell/bash_exports # Exports
    $HOME/.dotfiles/shell/bash_aliases # Aliases
    $HOME/.dotfiles/shell/functions/* # Functions
    $HOME/.dotfiles/shell/bash_prompt # Custom bash prompt
    $HOME/.dotfiles/shell/bash_paths # Path modifications
    $(brew --prefix)/etc/bash_completion # Bash completion (installed via Homebrew)
    $HOME/.bash_profile.local # Local and private settings not under version control (e.g. git credentials)
)

# if these files are readable, source them
for index in ${!files[*]}
do
    if [[ -r ${files[$index]} ]]; then
        source ${files[$index]}
    fi
done

}

これについて何か考えはありますか?また、oh-my-zsh と OS X Yosemite を使用しています。

4

1 に答える 1

1

あなたのリストを修正し ('$(brew --prefix)' 行を削除)、変更しました:

source ${files[$index]}

echo "source ${files[$index]}"

あなたの関数は私の Linux システムで正常に動作します。では、問題/解決策を特定する方法は?

  1. スクリプトに「隠し」コードはありますか? ## 猫 -v ~/some_bash_profile | もっと
  2. bash -n ~/some_bash_profile # エラーが発生した場合、Bash は文句を言います
  3. 各行を手動でソース # うまくいきますか?
于 2015-02-13T13:20:52.537 に答える