linux - 文件实际末尾出现意外的 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
语句和所有语法,但我无法弄清楚这个文件的语法错误。有什么我想念的吗?
解决方案
推荐阅读
- user-agent - User-Agent 信息无助于识别请求是来自 iPAD 还是 Safari 浏览器中的 MAC OS
- javascript - 如何使用 Angular 编写更短的代码函数类型脚本
- c# - 为包含多个集合作为子节点的 TreeView 节点构建数据模板的正确方法是什么?
- python - 如何为没有原始 PropertyMock 对象的断言获取 PropertyMock?
- asp.net - 无法在具有 Docker 支持和 Visual Studio 提供的 SQL Server 的 Visual Studio 中进行本地调试
- javascript - 为什么这个循环使用 Alpine.js 重复多次?
- excel - 当在该列中找到一个单词时,如何使该代码跨过该列?
- list - 使用 Google API 的时区列表
- scala - 以 Configuration 作为参数的模拟类
- java - 每当我尝试从服务器读取数据时,我都会在客户端收到套接字异常(连接重置)