Google Cloud SDK安装使用不正确的语法更改了bashrc

时间:2016-11-07 17:32:28

标签: bash gcloud google-cloud-sdk

Google Cloud SDK安装结束时。安装程序显示了这个

The Google Cloud SDK installer will now prompt you to update an rc
file to bring the Google Cloud CLIs into your environment.

Enter a path to an rc file to update, or leave blank to use
[/root/.bashrc]:
Backing up [/root/.bashrc] to [/root/.bashrc.backup].
[/root/.bashrc] has been updated.
Start a new shell for the changes to take effect.

但每次打开终端后都会更新。它会抛出错误

bash: /home/tessact/.bashrc: line 117: syntax error near unexpected token `fi'
bash: /home/tessact/.bashrc: line 117: `fi'
tessact@tessact-sys-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
#
# I am guessing the code below this was added by the installer
#
  source '/home/tessact/libs/google-cloud-sdk/path.bash.inc'
fi
  source '/home/tessact/libs/google-cloud-sdk/completion.bash.inc'
fi

# The next line updates PATH for the Google Cloud SDK.
if [ -f /home/tessact/developer/google-cloud-sdk/path.bash.inc ]; then
  source '/home/tessact/developer/google-cloud-sdk/path.bash.inc'
fi

# The next line enables shell command completion for gcloud.
if [ -f /home/tessact/developer/google-cloud-sdk/completion.bash.inc ]; then
  source '/home/tessact/developer/google-cloud-sdk/completion.bash.inc'
fi

正如我们所看到的,下面的代码块blsh开头没有“if”语句

  source '/home/tessact/libs/google-cloud-sdk/path.bash.inc'
fi

安装中是否有错误?我可以删除导致错误的两个fi语句

0 个答案:

没有答案