带有原始 .bashrc 的“语法错误:文件意外结束”

骆驼

我在这里不知所措。

Kubuntu 18.04.4 LTS

运行了几年。

bash: .bashrc: line 118: syntax error: unexpected end of file打开终端窗口时,突然间我得到“ ”。

我已经很久没有对这个文件做任何修改了。我仍然在寻找任何遗漏的结束语、遗漏的报价等。我什么也没找到。

我检查了行尾是否符合 UNIX 风格,并且确实如此。

这就是奇怪的地方:我最终将原始文件从 复制/etc/skel~/... 也没有运气!

这是我当前的内容~/.bashrc(就像我说的来自发行版的原始内容一样,这仍然给我同样的错误)。

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

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth

# append to the history file, don't overwrite it
shopt -s histappend

# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000

# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize

# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar

# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
    xterm-color|*-256color) color_prompt=yes;;
esac

# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes

if [ -n "$force_color_prompt" ]; then
    if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
        # We have color support; assume it's compliant with Ecma-48
        # (ISO/IEC-6429). (Lack of such support is extremely rare, and such
        # a case would tend to support setf rather than setaf.)
        color_prompt=yes
    else
        color_prompt=
    fi
fi

if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt

# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
    PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
    ;;
*)
    ;;
esac

# 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

# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'

# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'

# Add an "alert" alias for long running commands.  Use like so:
#   sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'

# 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

# 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

更新:总是用户错误。

正如@bhordupur 所建议的,我set -x在文件顶部添加了内容。我不会用输出污染线程,但它让我看到问题出在我的.bash_aliases(它被调用.bashrc并且我实际上也已经检查过,顺便说一句)。fi如果你能相信的话,我已经定义了一个名为 的别名所以当然这被解释为结束语if更改了别名的名称。问题解决了。

骆驼

问题出在我的.bash_aliases.bashrc顺便说一句,我也实际检查过)。fi如果你能相信的话,我已经定义了一个名为 的别名所以当然这被解释为结束语if更改了别名的名称。问题解决了。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

.bashrc语法错误:文件意外结束

.bashrc:语法错误:文件意外结束

bash:.bashrc:第 148 行:语法错误:文件意外结束

.bashrc文件语法错误在意外标记“(”附近

.bashrc:意外令牌'('附近的语法错误

语法错误:尽管所有语句均有效,但文件意外结束

文件bashrc意外结束

解析错误:语法错误,第179行中的文件意外结束(文件没有那么多行)

编辑.bashrc文件后,Ubuntu bash出现错误“意外令牌'newline'附近的语法错误”

编辑.bashrc后出现“意外令牌附近的语法错误”

我收到“语法错误,意外标记“endif”,期待文件结束”,我有点迷茫

有角度的,未捕获的语法错误:移至生产环境时输入意外结束

.bashrc是否包含语法错误?

bashrc 中的别名返回语法错误

文件 .bashrc 意外结束 Ubuntu 18.04

AWK - 语法错误:文件意外结束

bash:语法错误:文件意外结束

FatalErrorException:语法错误,文件意外结束

语法错误:带有嵌套 for 循环的意外标记

带有意外令牌的jQuery语法错误

bash:/home/gaja/.bashrc:第4行:意外令牌'('附近的语法错误

第63行:意外令牌';'附近的语法错误 在bashrc中

意外覆盖〜/ .bashrc文件

带有原始SQL语句的Laravel querybuilder返回语法错误

语法错误:bash中的文件意外结束错误

解析错误:语法错误,文件意外结束问题

PHP-解析错误:语法错误,文件意外结束

PHP:解析错误:语法错误,文件意外结束

PHP解析错误:语法错误,文件意外结束,应为“`”