当前时区为 UTC + 8 小时



发表新帖 回复这个主题  [ 12 篇帖子 ] 
作者 内容
1 楼 
 文章标题 : source /etc/bash.bashrc文件时错误提示,帮助查找。
帖子发表于 : 2013-04-21 17:39 

注册: 2008-06-07 20:40
帖子: 134
送出感谢: 2
接收感谢: 0 次
代码:
# 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 次

页首
 用户资料  
 
2 楼 
 文章标题 : Re: 帮助查看bash.bashrc文件错误!
帖子发表于 : 2013-04-21 17:55 

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


页首
 用户资料  
 
3 楼 
 文章标题 : Re: 帮助查看bash.bashrc文件错误!
帖子发表于 : 2013-04-21 18:36 

注册: 2008-06-07 20:40
帖子: 134
送出感谢: 2
接收感谢: 0 次
没人能帮到吗? :em06


页首
 用户资料  
 
4 楼 
 文章标题 : Re: source /etc/bash.bashrc文件时错误提示,帮助查找。
帖子发表于 : 2013-04-21 19:11 
头像

注册: 2011-06-07 14:20
帖子: 3866
系统: Mint18
送出感谢: 17
接收感谢: 65
[bash]# enable bash completion in interactive shells
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# . /etc/bash_completion
#fi[/bash]你的自动补全就没有打开,这里面if到fi这几行前面的#去掉
其他的问题我没看出来,要看行数


_________________
wiki: ubuntu 技巧


页首
 用户资料  
 
5 楼 
 文章标题 : Re: source /etc/bash.bashrc文件时错误提示,帮助查找。
帖子发表于 : 2013-04-21 19:18 

注册: 2008-06-07 20:40
帖子: 134
送出感谢: 2
接收感谢: 0 次
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行为空行


页首
 用户资料  
 
6 楼 
 文章标题 : Re: source /etc/bash.bashrc文件时错误提示,帮助查找。
帖子发表于 : 2013-04-21 19:26 

注册: 2008-06-07 20:40
帖子: 134
送出感谢: 2
接收感谢: 0 次
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


页首
 用户资料  
 
7 楼 
 文章标题 : Re: source /etc/bash.bashrc文件时错误提示,帮助查找。
帖子发表于 : 2013-04-21 19:31 
头像

注册: 2011-06-07 14:20
帖子: 3866
系统: Mint18
送出感谢: 17
接收感谢: 65
在文件末尾加一行空行
别的没发现有问题 :em06


_________________
wiki: ubuntu 技巧


页首
 用户资料  
 
8 楼 
 文章标题 : Re: source /etc/bash.bashrc文件时错误提示,帮助查找。
帖子发表于 : 2013-04-21 19:32 
头像

注册: 2011-06-07 14:20
帖子: 3866
系统: Mint18
送出感谢: 17
接收感谢: 65
: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]


_________________
wiki: ubuntu 技巧



_________________
评价: 3.7% gs-linux
 
页首
 用户资料  
 
9 楼 
 文章标题 : Re: source /etc/bash.bashrc文件时错误提示,帮助查找。
帖子发表于 : 2013-04-21 19:45 

注册: 2008-06-07 20:40
帖子: 134
送出感谢: 2
接收感谢: 0 次
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


页首
 用户资料  
 
10 楼 
 文章标题 : Re: source /etc/bash.bashrc文件时错误提示,帮助查找。
帖子发表于 : 2013-04-21 19:58 

注册: 2009-07-10 16:56
帖子: 35
系统: ubuntu
送出感谢: 0 次
接收感谢: 3
楼主把这段贴到终端里边自己看,正常吗?
代码:
    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-programming-languages-139/what-does-eof-do-328074.html
http://tldp.org/LDP/abs/html/here-docs.html#LIMITSTRDASH <--这书挺好的
代码:
[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 应该左起打头不要空。



_________________
评价: 3.7% gs-linux
 
页首
 用户资料  
 
11 楼 
 文章标题 : Re: source /etc/bash.bashrc文件时错误提示,帮助查找。
帖子发表于 : 2013-04-21 20:27 

注册: 2008-06-07 20:40
帖子: 134
送出感谢: 2
接收感谢: 0 次
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-programming-languages-139/what-does-eof-do-328074.html
http://tldp.org/LDP/abs/html/here-docs.html#LIMITSTRDASH <--这书挺好的
代码:
[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


页首
 用户资料  
 
12 楼 
 文章标题 : Re: source /etc/bash.bashrc文件时错误提示,帮助查找。
帖子发表于 : 2013-04-21 20:39 

注册: 2009-07-10 16:56
帖子: 35
系统: ubuntu
送出感谢: 0 次
接收感谢: 3
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-programming-languages-139/what-does-eof-do-328074.html
http://tldp.org/LDP/abs/html/here-docs.html#LIMITSTRDASH <--这书挺好的
代码:
[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

这个有中文版的,额,只看了一点...捂脸


页首
 用户资料  
 
显示帖子 :  排序  
发表新帖 回复这个主题  [ 12 篇帖子 ] 

当前时区为 UTC + 8 小时


在线用户

正在浏览此版面的用户:没有注册用户 和 4 位游客


不能 在这个版面发表主题
不能 在这个版面回复主题
不能 在这个版面编辑帖子
不能 在这个版面删除帖子
不能 在这个版面提交附件

前往 :  
本站点为公益性站点,用于推广开源自由软件,由 DiaHosting VPSBudgetVM VPS 提供服务。
我们认为:软件应可免费取得,软件工具在各种语言环境下皆可使用,且不会有任何功能上的差异;
人们应有定制和修改软件的自由,且方式不受限制,只要他们自认为合适。

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
简体中文语系由 王笑宇 翻译