首页 > 解决方案 > 文件实际末尾出现意外的 EOF 语法错误,没有任何语法错误

问题描述

我正在尝试使用 raspberry pi os 为 raspberry pi 编写 ~/.bashrc 文件,这就是我所拥有的(我自己的 PC 中默认提供的修改版本):

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples

#export PATH=~/.local/bin:/snap/bin:/usr/sandbox/:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games:/usr/share/games:/usr/local/sbin:/usr/sbin:/sbin:$PATH

# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
    test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
    alias ls='ls --color=auto'
    alias dir='dir --color=auto'
    alias vdir='vdir --color=auto'

    alias grep='grep --color=auto'
    alias fgrep='fgrep --color=auto'
    alias egrep='egrep --color=auto'
fi

    

# some more ls aliases
alias ll='ls -lh'
alias la='ls -lha'
alias l='ls -CF'
alias em='emacs -nw'
alias dd='dd status=progress'
alias _='sudo'
alias _i='sudo -i'
alias please='sudo'
alias fucking='sudo'

# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.

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

执行此代码时会弹出此错误:

-bash: $'\r': command not found
-bash: $'\r': command not found
-bash: .bashrc: line 39: syntax error: unexpected end of file

出于某种原因,它总是会抛出一个指向文件最后一行的 Unexpected EOF 错误,即使那里没有 EOF。我自己检查了所有引号、两个if语句和所有语法,但我无法弄清楚这个文件的语法错误。有什么我想念的吗?

标签: linuxbashshellsyntax-erroreof

解决方案


推荐阅读