bash:.bashrc:第 148 行:语法错误:意外的文件结束

bash:.bashrc:第 148 行:语法错误:意外的文件结束

我必须在 中设置路径.bashrc。我使用 打开它vi .bashrc,错误地省略了最后一行(包含 的内容fi),然后添加了路径。我使用 保存了它:wq。执行时source .bashrc显示:

bash: .bashrc: line 148: syntax error: unexpected end of file.

以下是最后几行~/.bashrc

if [ -f ~/.bash_aliases ]; then
    . ~/.bash_aliases
fi

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
PATH=$PATH:/home/rbh/PROGRAMS.330/bin 
export PATH

答案1

.bashrc应该看起来像这样

# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
  if [ -f /usr/share/bash-completion/bash_completion ]; then
    . /usr/share/bash-completion/bash_completion
  elif [ -f /etc/bash_completion ]; then
    . /etc/bash_completion
  fi
fi

PATH=$PATH:/home/rbh/PROGRAMS.330/bin export PATH

您删除了最后一个fi关闭 if 块条件的

相关内容