0

I'm getting a bad pattern output in my terminal:

   ➜  ~  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    )
   ➜  ~

This is part from 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

}

Any thoughts on this? Also I'm using oh-my-zsh and OS X Yosemite.

xeLL
  • 487
  • 2
  • 9
  • 24

1 Answers1

1

I modified your listing (removed the '$(brew --prefix)'line) and changed:

source ${files[$index]}

to

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

Your function works fine on my Linux system. So how to locate the issue/resolve?

  1. any 'hidden' codes in your script? ## cat -v ~/some_bash_profile | more
  2. bash -n ~/some_bash_profile # Bash will complain if errors
  3. source each line manually # work ok?
Dale_Reagan
  • 1,953
  • 14
  • 11
  • Thanks for response Dale! 1. http://pastebin.com/gXHB5K1F 2. no errors 3. nothing wrong all configuration is here: https://github.com/PavelDemyanenko/dotfiles I found out that this only happens with zsh configuration. – xeLL Mar 01 '15 at 20:51