.bashrc syntax error: unexpected end of file

前端 未结 8 647

I am getting an unexpected end of file error. I am not really sure how to fix it.

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bash         


        
相关标签:
8条回答
  • 2021-01-05 15:08

    I had the same error due to missing "fi" line. Make sure to omit syntax errors. The original .bashrc is located in /etc/skel/. So just run the following command:

    cp /etc/skel/.bashrc ~

    0 讨论(0)
  • 2021-01-05 15:12

    This .bashrc shall have been edited from windows. fromdos .bashrcé to correct this file in order to source it.

    0 讨论(0)
  • 2021-01-05 15:20

    Such syntax errors are really simple to find. At first glance the file looks okay, so I'd suggest you comment out every single line (with #) and see if the error still manifests.

    Then just do binary search, that is, comment in the first half of the file. If that works continue with the third quarter (otherwise with the first quarter). And so forth.

    0 讨论(0)
  • 2021-01-05 15:21

    I was facing a similar problem. Using the bash that comes with Windows 10, somehow the line endings had been changed to windows line endings (CRLF). Changing the file back to use unix line endings solved the issue.

    Convert eh line endings to unix endings and see if that solves the issue. If editing in Vim, enter the command :set fileformat=unix and save the file. Several other editors have the ability to convert line endings, such as Notepad++ or Atom

    0 讨论(0)
  • 2021-01-05 15:24

    . . . 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 In the first line of my terminal i got There is error at the end of the /.bashrc file but when i change Fi to fi it works fine like

    . . . . 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

    0 讨论(0)
  • 2021-01-05 15:27

    I had a similar problem, it turned out to be a missing "}" at the end of a function. I made a backup of the faulty one (in order to have an idea of what my setup was) and then copied the original fine (cp /etc/skel/.bashrc ~) and added the lines again.

    0 讨论(0)
提交回复
热议问题