You are not logged in.

#1 2013-08-27 22:56:14

MoonSwan
Member
From: Great White North
Registered: 2008-01-23
Posts: 873

[Solved] Sourcing .bashrc gets "syntax error: unexpected end of file"

I've looked at the wiki and the web as well as this forum for a clue as to why my .bashrc file spits out "syntax error: unexpected end of file."  On boot-up my user account gives me this error when I login to a TTY or open a terminal window.  As a result, my nice prompt that I spent some time developing doesn't work and my prompt instead defaults to a prompt I put into /etc/bash.bashrc just for fun.  That prompt gives you a smiley face if your last command worked or a frowny face if it failed.  Should anyone wish to use it, here it is:

 PS1="$(if [[ ${EUID} == 0 ]]; then echo '\[\033[01;31m\]\h'; else echo '\[\033[01;32m\]\u@\h'; fi)\[\033[01;34m\] \w \$([[ \$? != 0 ]] && echo \"\[\033[01;31m\]:(\[\033[01;34m\] \")
\\$\[\033[00m\] " 

I am posting the original .bashrc file and one stripped of all extraneous material in the hope that my mistake is more easily found.

My stripped down .bashrc I've used to try to debug this issue

if [[ $- != *i* ]] ; then
	# Shell is non-interactive.  Be done now!
	return

###Promts & Terminal theme is black on white

## name=dark purple; relative directory=medium purple; prompt=dark purple; font code=light grey
PS1='\[\e[0;35m\]\u\[\e[m\]\[\e[0;37m\] \W\[\e[m\]\[\e[0;35m\] \$ \[\e[m\]\[\e[0;37m\]'

## erase duplicate entries in your history file ~HL  June 2012
export HISTCONTROL=erasedups

# TMUX
if which tmux 2>&1 >/dev/null; then
   #if not inside a tmux session, and if no session is started, start a new session
    test -z "$TMUX" && (tmux attach || tmux new-session)
fi
###

## sets the default editor to be nano
export EDITOR="nano"
###

## You can enable code syntax coloring in less by installing "source-highlight"
export LESSOPEN="| /usr/bin/source-highlight-esc.sh %s"
export LESS='-R '
###

man() {
    env LESS_TERMCAP_mb=$(printf "\e[1;32m") \
	LESS_TERMCAP_md=$(printf "\e[0;32m") \
	LESS_TERMCAP_me=$(printf "\e[0m") \
	LESS_TERMCAP_se=$(printf "\e[0m") \
	LESS_TERMCAP_so=$(printf "\e[4;30;0;31m") \
	LESS_TERMCAP_ue=$(printf "\e[0m") \
	LESS_TERMCAP_us=$(printf "\e[1;33m") \
	man "$@"
}

The original .bashrc

# ~/.bashrc
# Test for an interactive shell.
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# and it's important to refrain from outputting anything in those cases. 
# So make sure this doesn't display anything or bad things will happen !

if [[ $- != *i* ]] ; then
	# Shell is non-interactive.  Be done now!
	return

###Prompts & Terminal theme is black on white

## name=dark purple; absolute directory=medium purple; prompt=dark purple; font code=light grey
PS1='\[\e[0;35m\]\u\[\e[m\]\[\e[0;37m\] \W\[\e[m\]\[\e[0;35m\] \$ \[\e[m\]\[\e[0;37m\]'

## Identical to previous prompt *BUT* this one *does not show your directory* location
#PS1='\[\e[0;35m\]\u\[\e[m\]\[\e[0;37m\][\e[m\]\[\e[0;35m\] \$ \[\e[m\]\[\e[0;37m\]'

## Bright purple user name, absolute directory location is shown and prompt with white text
#PS1='\[\e[0;35m\]\u\[\e[m\]\[\e[0;37m\] \W\[\e[m\]\[\e[0;35m\] \$ \[\e[m\]\[\e[1;37m\]'

## erase duplicate entries in your history file ~HL  June 2012
export HISTCONTROL=erasedups
### 

# Put this this snippet BEFORE the aliases in .bashrc.
# This code starts TMUX with only one session (unless you start some manually), on login; 
# it will try attach to a currently running session.
# If no session is already running TMUX will only create a session.

# TMUX
if which tmux 2>&1 >/dev/null; then
   #if not inside a tmux session, and if no session is started, start a new session
    test -z "$TMUX" && (tmux attach || tmux new-session)
fi
###
## sets the default editor to be nano
export EDITOR="nano"
###

## You can enable code syntax coloring in less by installing "source-highlight"
export LESSOPEN="| /usr/bin/source-highlight-esc.sh %s"
export LESS='-R '
###

#########################################
#                                       #
# Light Purple SSH Prompt for PinkYunzi #
#					#
#########################################

#if  -n "$SSH_CLIENT" ; then text=" ssh"
#fi
##
# export PS1='\\e1;35m\\u@\h:\w${text}$\\em\ '
###

# Coloured man pages
# 67: Primary colour for program names is Dark Green [old 80's CRT green!]
# 68: Optional arguments and/or separate options for arguments is Bright Green
# 69: Text Reset
# 70: Text Reset
# 71: man page info bottom of page is Dark Red on Black background (net effect is transparent background with red writing)
# 72: Text Reset
# 73: References to other programs (and their respective man page(s)) are Bright Yellow [good neutral yellow]
man() {
    env LESS_TERMCAP_mb=$(printf "\e[1;32m") \
	LESS_TERMCAP_md=$(printf "\e[0;32m") \
	LESS_TERMCAP_me=$(printf "\e[0m") \
	LESS_TERMCAP_se=$(printf "\e[0m") \
	LESS_TERMCAP_so=$(printf "\e[4;30;0;31m") \
	LESS_TERMCAP_ue=$(printf "\e[0m") \
	LESS_TERMCAP_us=$(printf "\e[1;33m") \
	man "$@"
}
###

I am grateful to this community's efforts and it is due to those efforts that I have rarely had to actually post to this forum seeking guidance for my problems.

This is, I'm sure, a trivial issue to solve but I have thus far failed to do so. 

Thank you,
MS

Last edited by MoonSwan (2013-08-27 23:51:04)


I'm torn apart between worlds. Basically, using vim in a highly visual environment with a lot of mouse features feels like soldering a lose wire to a motherboard with a Zippo and a needle, while working with ANY TEXT AT ALL with a "modern GUI" text editor feels like joining the London Philharmonic Orchestra with a Fisher-Price Laugh and Learn Magical Musical Mirror.  --Awebb

Offline

#2 2013-08-27 22:58:45

jasonwryan
Anarchist
From: .nz
Registered: 2009-05-09
Posts: 26,250
Website

Re: [Solved] Sourcing .bashrc gets "syntax error: unexpected end of file"

There is no fi closing your opening if...


Arch + dwm   •   Mercurial repos  •   Github

Registered Linux User #482438

Online

#3 2013-08-27 22:59:34

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 6,100

Re: [Solved] Sourcing .bashrc gets "syntax error: unexpected end of file"

The first if is not closed by fi.

EDIT: Too slow sad.

Last edited by cfr (2013-08-27 23:00:09)


How To Ask Questions The Smart Way | Help Vampires

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Corporation Wireless 8265 / 8275 | US keyboard with Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#4 2013-08-27 23:01:51

MoonSwan
Member
From: Great White North
Registered: 2008-01-23
Posts: 873

Re: [Solved] Sourcing .bashrc gets "syntax error: unexpected end of file"

Good gods I'm an idiot!  Thank you very much, I shall now slink back under my rock and proceed to pound my head against it till the next time I have a perverse desire to look foolish on a public forum.


I'm torn apart between worlds. Basically, using vim in a highly visual environment with a lot of mouse features feels like soldering a lose wire to a motherboard with a Zippo and a needle, while working with ANY TEXT AT ALL with a "modern GUI" text editor feels like joining the London Philharmonic Orchestra with a Fisher-Price Laugh and Learn Magical Musical Mirror.  --Awebb

Offline

Board footer

Powered by FluxBB