Linux .!(|.| git)在shell启动的早期会导致语法错误,但不会在以后

Linux .!(|.| git)在shell启动的早期会导致语法错误,但不会在以后,linux,bash,Linux,Bash,我在我的bash主文件夹(.bashrc、.bash_profile、.alisese、.vimrc…)中自定义了一些文件,并将它们放在git存储库中,以便在不同的计算机上工作时具有相同的配置。我已经在一些电脑上测试过了,但其中一台电脑却失败了。请阅读下面的内容 My.bashrc sources.bash_配置文件,包含以下内容: 1 [ -n "$PS1" ] && source ~/.bash_profile; 4 # Load the shell dotfile

我在我的bash主文件夹(.bashrc、.bash_profile、.alisese、.vimrc…)中自定义了一些文件,并将它们放在git存储库中,以便在不同的计算机上工作时具有相同的配置。我已经在一些电脑上测试过了,但其中一台电脑却失败了。请阅读下面的内容

My.bashrc sources.bash_配置文件,包含以下内容:

  1 [ -n "$PS1" ] && source ~/.bash_profile;
  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;
然后加载.bash_配置文件(以及其他文件)。函数如下:

  1 [ -n "$PS1" ] && source ~/.bash_profile;
  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;
最后,函数具有以下功能:

  6 function source_repo {
  7 echo "Sourcing bash files form repo."
  8 cp .!(|.|git) ~/
  9 }
在使用UbuntuforWindows10时,我在启动时bash sources.functions第8行出现错误。 以下是错误信息

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 ~
$
(对我来说)奇怪的是,我可以在以后手动获取文件(.functions)的源代码,而不会出现任何问题。 我对LinuxBash的了解有限。我尝试使用chmod 777处理所有涉及的文件(.bashrc、.bash_profile和.functions),但没有成功。 任何帮助都将不胜感激!
在这一点上,bash没有启用“扩展全局绑定”。在源文件之前,先将
shopt-s extglob
添加到.bashrc中。

我做同样的事情,使用我源文件中的一堆bash dot文件。其中一个是
~/.bash\u shopt
谢谢你,格伦。工作正常。非常感谢