2

在 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

我们可以看到下面显示的代码块以没有“if”语句开头

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

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

4

0 回答 0