0

I have customized some files on my bash home folder (.bashrc, .bash_profile, .alisese, .vimrc...) and put them in a git repository to have the same configuration when working on different computers. I have tested it ok on some computers but for one of them it is failing. Please read below.

My .bashrc sources .bash_profile with this:

  1 [ -n "$PS1" ] && source ~/.bash_profile;

Then the .bash_profile loads (among other files) .functions with this:

  4 # Load the shell dotfiles, and then some:
  5 # * ~/.path can be used to extend `$PATH`.
  6 # * ~/.extra can be used for other settings you don’t want to commit.
  7 for file in ~/.{path,bash_prompt,exports,aliases,functions,extra}; do
  8     [ -r "$file" ] && [ -f "$file" ] && source "$file";
  9 done;
 10 unset file;

Finally .functions have this function:

  6 function source_repo {
  7 echo "Sourcing bash files form repo."
  8 cp .!(|.|git) ~/
  9 }

When working on Ubuntu for Windows 10 I get an error when bash sources .functions on startup, line 8. Here is the error:

bash: /home/fvarela/.functions: line 8: syntax error near unexpected token `('
bash: /home/fvarela/.functions: line 8: `cp .!(|.|git) ~/'

fvarela at MA8L201Y4Q2 in ~
$ source .functions

fvarela at MA8L201Y4Q2 in ~
$

Strange thing (for me) is that I can manually source the file (.functions) later manually without issues. My knowledge on Linux bash is limited. I have tried with chmod 777 to all files involved (.bashrc, .bash_profile and .functions) with no success. Any help will be appreciated! Regards

Charles Duffy
  • 280,126
  • 43
  • 390
  • 441

1 Answers1

1

At that point, bash does not have "extended globbing" enabled. Add shopt -s extglob to your .bashrc before you source the files.

glenn jackman
  • 238,783
  • 38
  • 220
  • 352