LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   source bashrc -> syntax error: unexpected end of file (https://www.linuxquestions.org/questions/slackware-14/source-bashrc-syntax-error-unexpected-end-of-file-851121/)

xri 12-18-2010 03:50 PM

source bashrc -> syntax error: unexpected end of file
 
I don't remember making any changes on any of these files on my account:
.bashrc
.bash_profile
.bash_logout
However, when I log into my slack box through ssh from another place, I get this error message:
Quote:

-bash /home/xri/.bashrc syntax error: unexpected end of file
-bash /home/xri/.bash_profile syntax error: unexpected end of file
Once inside my slackbox, after source <.bashrc | .bash_profile | .bash_logout>, I get the same error message, with all of them.
I checked them all, inside vim, which highlights the code, and I did not find anything unusual.

This is puzzling. I don't know what to look at.Could somebody give me a hint?

Thanks for reading this.

rg3 12-18-2010 04:00 PM

Can you paste the actual file contents? That would be a good start.

xri 12-19-2010 10:59 AM

course, sorry :)

Quote:

# ~/.bashrc
#
# see /etc/bashrc for a complete description how all bash source files
# are related and used on this box

# Source system-wide aliases and functions
if [ -f /etc/bashrc ]; then
source /etc/bashrc
fi

# --- Local/Personal environment variables ---
# define bash prompts, non-X text editors, etc.
unset MAILCHECK

# --- Local aliases ---
# Listing and cd
alias ll='ls -lh --color|most'
alias la='ls -lah --color|most'
alias lt='ls -ltrh --color|most'
alias ls='ls --color'
alias l='ls -l --color'
alias d='pwd'
alias dow='cd /home/xri/downloads'
alias co='cd /home/xri/const'
alias pr='cd /home/xri/newsoftware'
alias is='cd /home/xri/isos'
alias fl='cd /home/xri/.fluxbox'
alias ..='cd ..'
alias cl='clear'

# Locally
alias find='find . -iname'
alias ft='find . -ctime'
alias me='echo 'rig' && uname -n && echo 'ME' && whoami && echo 'LOCATION' && pwd '
alias pgrep='pgrep -l'

# On the net
alias lya='lynx wiki.archlinux.org'
alias lyn='lynx www.linuxquestions.org'
alias g='google -search=linux'
alias wk='wikipedia'

# This system
alias mo='mount|grep -v logi|grep -v tmp|grep -v usb|grep -v fuse'
alias ml='mount|grep logi'
alias mf='mount|grep fuse'
alias df='df -h'
alias ram='free -m'

# This file
alias cm='vim ~/.bashrc'
alias cmm='source ~/.bashrc'

#################################################
# --- Local functions ---

export PATH=$PATH:/usr/sbin:/home/xri/newsoftware
complete -cf sudo

#################################################
# Necessary for now
if [ -f /home/xri/personal/somedata.kdb.lock ]; then
rm /home/xri/personal/somedata.kdb.lock
fi
##################################################
# More important actions
alias m='msgc'
alias n='notesshort'
alias cla='sgc-claws'
alias comp='src2pkg'

##################################################
# Activated at startup
Quote:

# ~/.bash_profile
#
# see /etc/bashrc for a complete description how all bash source files
# are related and used on this box

# Source Local/Personal aliases and functions
if [ -f $HOME/.bashrc ]; then
source $HOME/.bashrc
fi

# Source /usr/local/bin/bash_login
if [ -x /usr/local/bin/bash_login ]; then
/usr/local/bin/bash_login
fi

# --- Local/Personal startup programs ---
Quote:

# ~/.bash_logout
#
# see /etc/bashrc for a complete description how all bash source files
# are related and used on this box

# Source /usr/local/bin/bash_logout
if [ -x /usr/local/bin/bash_logout ]; then
/usr/local/bin/bash_logout
fi


rm /home/ele/algo/trivialidades.kdb.lock
I haven't edited any of them recently, let alone all three of them.
However, out of a sudden, I'm getting these error messages:

Quote:

bash-4.1$ source .bashrc
bash: ./.bashrc: line 73: syntax error: unexpected end of file
bash-4.1$ source .bash_profile
bash: ./.bash_profile: line 16: syntax error: unexpected end of file
bash-4.1$ source .bash_logout
bash: ./.bash_logout: line 13: syntax error: unexpected end of file

gnashley 12-19-2010 11:23 AM

Is this all on one line?:
alias me='echo 'rig' && uname -n && echo 'ME' && whoami && echo 'LOCATION' && pwd'
If not, try making it so. Another thing you might try is having a an empty newline at the end of each file -have you upgraded bash recently?

T3slider 12-19-2010 01:11 PM

Does that line that gnashley noted actually work? You're using a single quote to denote the contents of the alias but using the same single quote within the alias definition...I would think it would be breaking in and out of the alias definition.

Keith Hedger 12-19-2010 01:29 PM

Well I just tried temporarily replacing my bashrc and bash_profile with the ones you posted and they work fine ( except any missing programs/folders/files that you may have installed that I don't ) maybe the files themselves have been corupted, I just tried changing the line ends to dos type via the todos command and now get the same errors as you are getting so I guess thats a good place to start.

jamesf 12-19-2010 02:06 PM

Quote:

Originally Posted by T3slider (Post 4196934)
Does that line that gnashley noted actually work? You're using a single quote to denote the contents of the alias but using the same single quote within the alias definition...I would think it would be breaking in and out of the alias definition.

Yes, it appears to (but the inner quotes are all stripped from the alias:
Code:

bash-4.1$ alias me='echo 'rig' && uname -n && echo 'ME' && whoami && echo 'LOCATION' && pwd'
bash-4.1$ alias
alias me='echo rig && uname -n && echo ME && whoami && echo LOCATION && pwd'
bash-4.1$ me
rig
darkstar
ME
james
LOCATION
/home/james
bash-4.1$

He's sourcing /etc/bashrc in his first two scripts, but on my machine:
Code:

bash-4.1$ cat /etc/bashrc           
cat: /etc/bashrc: No such file or directory
bash-4.1$

But I bet that Keith Hedger (above) is onto something with the line endings.

xri 12-19-2010 03:15 PM

1 Attachment(s)
Quote:

Originally Posted by gnashley (Post 4196863)
Is this all on one line?:
alias me='echo 'rig' && uname -n && echo 'ME' && whoami && echo 'LOCATION' && pwd'
If not, try making it so. Another thing you might try is having a an empty newline at the end of each file -have you upgraded bash recently?

Thanks for the input, all of you.
  1. The line actually works as it is (I always use it, and I'm using it right now).
  2. I have not upgraded bash recently. It's all original slack, with some slackbuilds on top of it.
  3. I have not touched the files in question with any DOS or Windows tool at all. However, I'm very interested in following on Keith Hedger's idea, although I don't know how to do that at this point.

By the way, I'm uploading a snapshot of all my installed programs, and when they were installed. Sorry, I could not paste the content here ('too many characters').

mRgOBLIN 12-19-2010 03:50 PM

Code:

fromdos < oldfile > newfile
Oh and you can check the line endings with
Code:

cat -A some_file

Keith Hedger 12-19-2010 04:54 PM

You can also check for odd characters that don't get printed by
Code:

hexdump -C .bashrc

00000000  23 21 2f 62 69 6e 2f 62  61 73 68 0a 23 20 7e 2f  |#!/bin/bash.# ~/|
00000010  2e 62 61 73 68 72 63 3a  20 65 78 65 63 75 74 65  |.bashrc: execute|
00000020  64 20 62 79 20 62 61 73  68 28 31 29 20 66 6f 72  |d by bash(1) for|
00000030  20 6e 6f 6e 2d 6c 6f 67  69 6e 20 73 68 65 6c 6c  | non-login shell|
...

the 0a is the correct linux line ending, if its a dos line ending it will be 0d 0a

xri 12-22-2010 08:29 AM

Sorry for some delay to post again. The last few days have been hectic.

fromdos < .bashrc > newfile
source newfile gives me the same error message

cat -A .bashrc
every single line (including a couple of final empty lines) ends with "$"

hexdump -C .bashrc
the output shows several "0a" but no "0d 0a".

catkin 12-22-2010 08:40 AM

You could try progressively commenting out lines in the hope of identifying the problem line(s). .bash_logout, being the shortest would be a good one to start with.

xri 12-22-2010 09:01 AM

I found something else. The problem seems to be on the "if" statements.

Quote:

f [ -f /etc/bashrc ]; then
source /etc/bashrc
fi
Quote:

if [ -f /home/xri/personal/somedata.kdb.lock ]; then
rm /home/xri/personal/somedata.kdb.lock
fi

When I comment out both, then I get no error messages.
If I uncomment either one, then I get the same error message shown on the initial post.

Why? Are they incorrect? The first one came with the freshly installed Slack and never gave me problems before.

xri 12-22-2010 09:05 AM

catkin, I just found your post; while you were writing it, I was doing exactly what you were suggesting :)
The only thing, I was doing it on .bashrc.

catkin 12-22-2010 09:14 AM

Try running unalias -a before sourcing, with the if-fi blocks uncommented.


All times are GMT -5. The time now is 02:11 PM.