ubuntuusers.de

Problem mit bash.bashrc im Terminal

Status: Gelöst | Ubuntu-Version: Ubuntu 16.04 (Xenial Xerus)
Antworten |

havelman

Anmeldungsdatum:
16. Februar 2016

Beiträge: 22

Hallo,

ich erhalte in der ersten Zeile im Terminal die Meldung:

bash: /etc/bash.bashrc: Zeile 143: Syntaxfehler: Unerwartetes Dateiende.

Danach ist alles ganz normal.

Was genau bedeutet das? Ich musste bei der bash.bashrc bei der Einrichtung von Java Development Kit (JDK) etwas machen. Ich kann mich aber aber nicht mehr erinnern, was genau ich da gemacht habe. Mir fiel es im Terminal erst später auf.

unbuntuS12

Anmeldungsdatum:
2. Juni 2010

Beiträge: 1816

Dann zeig doch mal her...

cat /etc/bash.bashrc

havelman

(Themenstarter)

Anmeldungsdatum:
16. Februar 2016

Beiträge: 22

Die Terminal-Ausgabe:

thomas@Thomas-Laptop ~ $ cat /etc/bash.bashrc
# System-wide .bashrc file for interactive bash(1) shells.

# To enable the settings / commands in this file for login shells as well,
# this file has to be sourced in /etc/profile.

# If not running interactively, don't do anything
[ -z "$PS1" ] && return

# 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

use_color=false

# Set colorful PS1 only on colorful terminals.
# dircolors --print-database uses its own built-in database
# instead of using /etc/DIR_COLORS.  Try to use the external file
# first to take advantage of user additions.  Use internal bash
# globbing instead of external grep binary.
safe_term=${TERM//[^[:alnum:]]/?}   # sanitize TERM
match_lhs=""
[[ -f ~/.dir_colors   ]] && match_lhs="${match_lhs}$(<~/.dir_colors)"
[[ -f /etc/DIR_COLORS ]] && match_lhs="${match_lhs}$(</etc/DIR_COLORS)"
[[ -z ${match_lhs}    ]] \
        && type -P dircolors >/dev/null \
        && match_lhs=$(dircolors --print-database)
[[ $'\n'${match_lhs} == *$'\n'"TERM "${safe_term}* ]] && use_color=true

if ${use_color} ; then
        # Enable colors for ls, etc.  Prefer ~/.dir_colors #64489
        if type -P dircolors >/dev/null ; then
                if [[ -f ~/.dir_colors ]] ; then
                        eval $(dircolors -b ~/.dir_colors)
                elif [[ -f /etc/DIR_COLORS ]] ; then
                        eval $(dircolors -b /etc/DIR_COLORS)
        else
            eval $(dircolors)
                fi
        fi

        if [[ ${EUID} == 0 ]] ; then
                PS1='${debian_chroot:+($debian_chroot)}\[\033[01;31m\]\h\[\033[01;34m\] \W \$\[\033[00m\] '
        else
                PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '
        fi

        alias ls='ls --color=auto'
        alias grep='grep --colour=auto'
        alias fgrep='fgrep --color=auto'
        alias egrep='egrep --color=auto'
else
        if [[ ${EUID} == 0 ]] ; then
                # show root@ when we don't have colors
                PS1='\u@\h \W \$ '
        else
                PS1='\u@\h \w \$ '
        fi
fi

# 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

# Try to keep environment pollution down, EPA loves us.
unset use_color safe_term match_lhs

# Commented out, don't overwrite xterm -T "title" -n "icontitle" by default.
# If this is an xterm set the title to user@host:dir
#case "$TERM" in
#xterm*|rxvt*)
#    PROMPT_COMMAND='echo -ne "\033]0;${USER}@${HOSTNAME}: ${PWD}\007"'
#    ;;
#*)
#    ;;
#esac

# enable bash completion in interactive shells
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

# if the command-not-found package is installed, use it
if [ -x /usr/lib/command-not-found -o -x /usr/share/command-not-found/command-not-found ]; then
    function command_not_found_handle {
            # check because c-n-f could've been removed in the meantime
                if [ -x /usr/lib/command-not-found ]; then
           /usr/lib/command-not-found -- "$1"
                   return $?
                elif [ -x /usr/share/command-not-found/command-not-found ]; then
           /usr/share/command-not-found/command-not-found -- "$1"
                   return $?
        else
           printf "%s: command not found\n" "$1" >&2
           return 127
        fi
    }
fi

if [ -x /usr/bin/mint-fortune ]; then
    /usr/bin/mint-fortune
fiexport PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/android-sdk/platform-tools

Ich sehe schon "android-sdk". Das hat auf jeden Fall was damit zu tun, weil ich für die Installation von Android Studio Java Development Kit installieren musste und da habe ich etwas geändert in dieser bash.

Bearbeitet von redknight:

Codeblock! Bitte nutze die korrekten Syntaxelemente

coram

Anmeldungsdatum:
17. Januar 2015

Beiträge: 645

Wohnort: Freiburg

Da Du die Ausgabe des cat-Befehls leider als Zitat und nicht als Codeblock formatiert hast, werden nicht alle Zeilenumbrüche korrekt dargestellt. Trotzdem ist der Fehler eindeutig zu erkennen 😉 : Der if-Anweisung ganz am Ende fehlt das abschließende "fi"!

Rufe mit Root-Rechten die Datei bash.bashrc im Editor auf

gksudo gedit /etc/bash.bashrc

füge ganz am Schluß in einer neuen Zeile das fehlende

fi

ein und speichere die geänderte Datei.

Edit: Jetzt, nachdem redknight dankenswerterweise die Formatierung bearbeitet hat, sieht es für mich so aus, als ob das fragliche "fi" in der /etc/bash.bashrc zwar vorhanden, aber vor das "export" verrutscht ist. Falls dem so ist, musst Du natürlich dieses falsche "fi" entfernen und stattdessen in eine neue letzte Zeile einfügen. Möglicherweise ist aber auch diese ganze letzte if-Anweisung irgendwie verunglückt – um das zu beurteilen, fehlen mir die inhaltlichen Kenntnisse.

havelman

(Themenstarter)

Anmeldungsdatum:
16. Februar 2016

Beiträge: 22

Nach dem direkten Versuch, eine weitere Zeile einzufügen und zu speichern, erhielt ich im Terminal:

bash: /etc/bash.bashrc: Zeile 143: Syntaxfehler: Unerwartetes Dateiende.
thomas@Thomas-Laptop ~ $ gksudo gedit /etc/bash.bashrc

(gedit:2728): Gtk-WARNING **: Attempting to store changes into `/root/.local/share/recently-used.xbel', but failed: Datei »/root/.local/share/recently-used.xbel.1AT1JY« konnte nicht angelegt werden: Datei oder Verzeichnis nicht gefunden

(gedit:2728): Gtk-WARNING **: Attempting to set the permissions of `/root/.local/share/recently-used.xbel', but failed: Datei oder Verzeichnis nicht gefunden

(gedit:2728): Gtk-WARNING **: Attempting to store changes into `/root/.local/share/recently-used.xbel', but failed: Datei »/root/.local/share/recently-used.xbel.B8KTJY« konnte nicht angelegt werden: Datei oder Verzeichnis nicht gefunden

(gedit:2728): Gtk-WARNING **: Attempting to set the permissions of `/root/.local/share/recently-used.xbel', but failed: Datei oder Verzeichnis nicht gefunden

Wenn ich ihn nun schließe und wieder öffne, bekomme ich:

Der Befehl »fiexport« wurde nicht gefunden, meinten Sie vielleicht:
 Befehl »ifexport« aus dem Paket »ctsim« (universe)
fiexport: Befehl nicht gefunden.
thomas@Thomas-Laptop ~ $ 

Spätestens jetzt hab ich null Plan mehr, was ich da tu.

HaCeMei Team-Icon

Anmeldungsdatum:
2. August 2010

Beiträge: 2265

Der Schluss deiner bash.bashrc sollte wohl so aussehen (Absatz nach fi beachten)

1
2
3
4
5
if [ -x /usr/bin/mint-fortune ]; then
    /usr/bin/mint-fortune
fi

export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/android-sdk/platform-tools

havelman

(Themenstarter)

Anmeldungsdatum:
16. Februar 2016

Beiträge: 22

Ja, scheint so. Die Meldung im Terminal ist zumindest weg ☺. Vielen Dank.

Antworten |