source /etc/bash.bashrc文件时错误提示,帮助查找。

为当前最终发行版之前的所有版本提供支持
回复
gs-linux
帖子: 134
注册时间: 2008-06-07 20:40
送出感谢: 2 次
接收感谢: 0

source /etc/bash.bashrc文件时错误提示,帮助查找。

#1

帖子 gs-linux » 2013-04-21 17:39

代码: 全选

# 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

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

# 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, overwrite the one in /etc/profile)
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

# 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 [ -f /etc/bash_completion ] && ! shopt -oq posix; then
#    . /etc/bash_completion
#fi

# sudo hint
if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; then
    case " $(groups) " in *\ admin\ *)
    if [ -x /usr/bin/sudo ]; then
    cat <<-EOF
    To run a command as administrator (user "root"), use "sudo <command>".
    See "man sudo_root" for details.
    
    EOF
    fi
    esac
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/bin/python /usr/lib/command-not-found -- "$1"
                   return $?
                elif [ -x /usr/share/command-not-found/command-not-found ]; then
           /usr/bin/python /usr/share/command-not-found/command-not-found -- "$1"
                   return $?
        else
           printf "%s: command not found\n" "$1" >&2
           return 127
        fi
    }
fi
我执行

代码: 全选

source /etc/bash.bashrc
时出现

代码: 全选

bash: 警告: 立即文档在第 40 行被文件结束符分隔 (需要 `EOF')
bash: /etc/bash.bashrc: 行 65: 语法错误: 未预期的文件结尾
的错误,不知如何修改。
谢谢!
系统版本为ubuntu12.10
此外在终端用vim或者latex按tab键无法补全总是出现如下错误

代码: 全选

bash: _init_completion: 未找到命令

代码: 全选

没有 bash.bashrc 的手册页条目
搜索google也无解! :em20
上次由 gs-linux 在 2013-04-21 18:58,总共编辑 2 次。
gs-linux
帖子: 134
注册时间: 2008-06-07 20:40
送出感谢: 2 次
接收感谢: 0

Re: 帮助查看bash.bashrc文件错误!

#2

帖子 gs-linux » 2013-04-21 17:55

没人看吗?自己顶下! :em06
gs-linux
帖子: 134
注册时间: 2008-06-07 20:40
送出感谢: 2 次
接收感谢: 0

Re: 帮助查看bash.bashrc文件错误!

#3

帖子 gs-linux » 2013-04-21 18:36

没人能帮到吗? :em06
头像
b33e
论坛版主
帖子: 3866
注册时间: 2011-06-07 14:20
系统: Mint18
送出感谢: 16 次
接收感谢: 62 次

Re: source /etc/bash.bashrc文件时错误提示,帮助查找。

#4

帖子 b33e » 2013-04-21 19:11

[bash]# enable bash completion in interactive shells
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# . /etc/bash_completion
#fi[/bash]你的自动补全就没有打开,这里面if到fi这几行前面的#去掉
其他的问题我没看出来,要看行数
gs-linux
帖子: 134
注册时间: 2008-06-07 20:40
送出感谢: 2 次
接收感谢: 0

Re: source /etc/bash.bashrc文件时错误提示,帮助查找。

#5

帖子 gs-linux » 2013-04-21 19:18

b33e 写了:[bash]# enable bash completion in interactive shells
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# . /etc/bash_completion
#fi[/bash]你的自动补全就没有打开,这里面if到fi这几行前面的#去掉
其他的问题我没看出来,要看行数
错误提示在第40行和第65行
第40行

代码: 全选

   cat <<-EOF
第65行为空行
gs-linux
帖子: 134
注册时间: 2008-06-07 20:40
送出感谢: 2 次
接收感谢: 0

Re: source /etc/bash.bashrc文件时错误提示,帮助查找。

#6

帖子 gs-linux » 2013-04-21 19:26

b33e 写了:[bash]# enable bash completion in interactive shells
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# . /etc/bash_completion
#fi[/bash]你的自动补全就没有打开,这里面if到fi这几行前面的#去掉
其他的问题我没看出来,要看行数
能否将你完整的bash.bashrc贴一下,我对照找一找?多谢 :em01
头像
b33e
论坛版主
帖子: 3866
注册时间: 2011-06-07 14:20
系统: Mint18
送出感谢: 16 次
接收感谢: 62 次

Re: source /etc/bash.bashrc文件时错误提示,帮助查找。

#7

帖子 b33e » 2013-04-21 19:31

在文件末尾加一行空行
别的没发现有问题 :em06
头像
b33e
论坛版主
帖子: 3866
注册时间: 2011-06-07 14:20
系统: Mint18
送出感谢: 16 次
接收感谢: 62 次

Re: source /etc/bash.bashrc文件时错误提示,帮助查找。

#8

帖子 b33e » 2013-04-21 19:32

:em01[bash]# 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

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

# 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, overwrite the one in /etc/profile)
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

# 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

# sudo hint
if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; then
case " $(groups) " in *\ admin\ *)
if [ -x /usr/bin/sudo ]; then
cat <<-EOF
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

EOF
fi
esac
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

[/bash]
这些用户感谢了作者 b33e 于这个帖子:
gs-linux (2013-04-21 19:46)
评价: 3.7%
gs-linux
帖子: 134
注册时间: 2008-06-07 20:40
送出感谢: 2 次
接收感谢: 0

Re: source /etc/bash.bashrc文件时错误提示,帮助查找。

#9

帖子 gs-linux » 2013-04-21 19:45

b33e 写了::em01[bash]# 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

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

# 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, overwrite the one in /etc/profile)
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '

# 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

# sudo hint
if [ ! -e "$HOME/.sudo_as_admin_successful" ] && [ ! -e "$HOME/.hushlogin" ] ; then
case " $(groups) " in *\ admin\ *)
if [ -x /usr/bin/sudo ]; then
cat <<-EOF
To run a command as administrator (user "root"), use "sudo <command>".
See "man sudo_root" for details.

EOF
fi
esac
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

[/bash]
我对照了一遍也没发现什么问题,我将你的文件完整copy过去 source就没错误提示了。 好奇怪 :em20
但是vim依旧不能补全命令 gedit 倒是可以 搞不懂。。谢谢了哦! :em03
newzxl
帖子: 35
注册时间: 2009-07-10 16:56
系统: ubuntu
送出感谢: 0
接收感谢: 3 次

Re: source /etc/bash.bashrc文件时错误提示,帮助查找。

#10

帖子 newzxl » 2013-04-21 19:58

楼主把这段贴到终端里边自己看,正常吗?

代码: 全选

    cat <<-EOF
    To run a command as administrator (user "root"), use "sudo <command>".
    See "man sudo_root" for details.
    
    EOF
看看这里 http://forums.devshed.com/other-program ... 28074.html
http://tldp.org/LDP/abs/html/here-docs. ... MITSTRDASH <--这书挺好的

代码: 全选

[mb@ironmaiden mb]$ cat >> test <<HERE
> Hello world HERE <--- Not the end of string
> This is a test
>  HERE <-- Leading space, so not end of string
> and a new line
> HERE <-- Now we have the end of the string
和 man bash 的 Here Document 吧。似乎你的那个 EOF 应该左起打头不要空。
这些用户感谢了作者 newzxl 于这个帖子:
gs-linux (2013-04-21 20:27)
评价: 3.7%
gs-linux
帖子: 134
注册时间: 2008-06-07 20:40
送出感谢: 2 次
接收感谢: 0

Re: source /etc/bash.bashrc文件时错误提示,帮助查找。

#11

帖子 gs-linux » 2013-04-21 20:27

newzxl 写了:楼主把这段贴到终端里边自己看,正常吗?

代码: 全选

    cat <<-EOF
    To run a command as administrator (user "root"), use "sudo <command>".
    See "man sudo_root" for details.
    
    EOF
看看这里 http://forums.devshed.com/other-program ... 28074.html
http://tldp.org/LDP/abs/html/here-docs. ... MITSTRDASH <--这书挺好的

代码: 全选

[mb@ironmaiden mb]$ cat >> test <<HERE
> Hello world HERE <--- Not the end of string
> This is a test
>  HERE <-- Leading space, so not end of string
> and a new line
> HERE <-- Now we have the end of the string
和 man bash 的 Here Document 吧。似乎你的那个 EOF 应该左起打头不要空。
谢谢啊,这才是从源头上解决问题了。改天好好看看你推荐的那本Advanced Bash-Scripting Guide实在太赞了! :em02
newzxl
帖子: 35
注册时间: 2009-07-10 16:56
系统: ubuntu
送出感谢: 0
接收感谢: 3 次

Re: source /etc/bash.bashrc文件时错误提示,帮助查找。

#12

帖子 newzxl » 2013-04-21 20:39

gs-linux 写了:
newzxl 写了:楼主把这段贴到终端里边自己看,正常吗?

代码: 全选

    cat <<-EOF
    To run a command as administrator (user "root"), use "sudo <command>".
    See "man sudo_root" for details.
    
    EOF
看看这里 http://forums.devshed.com/other-program ... 28074.html
http://tldp.org/LDP/abs/html/here-docs. ... MITSTRDASH <--这书挺好的

代码: 全选

[mb@ironmaiden mb]$ cat >> test <<HERE
> Hello world HERE <--- Not the end of string
> This is a test
>  HERE <-- Leading space, so not end of string
> and a new line
> HERE <-- Now we have the end of the string
和 man bash 的 Here Document 吧。似乎你的那个 EOF 应该左起打头不要空。
谢谢啊,这才是从源头上解决问题了。改天好好看看你推荐的那本Advanced Bash-Scripting Guide实在太赞了! :em02
这个有中文版的,额,只看了一点...捂脸
回复

回到 “老旧版本支持”