0

我得到了一个unexpected end of file on line 27这个脚本,它不是我写的,但出现在我的 /etc/profile 文件夹中,显然是为了为我的 BASH shell 控制台设置环境变量而执行的。所以每次我启动一个新的控制台时,我都会收到这个错误,这很烦人。

谁能帮我找出问题所在?有 2 个脚本...都是 c-shell 脚本 (*.csh)

这是第一个给我的第一个错误(libglib2.csh):

#! /bin/csh
#
# Description:  This script sets the environment variables G_FILENAME_ENCODING
# and G_BROKEN_FILENAMES for the glib-2.0 library.
#
# G_FILENAME_ENCODING
#       This environment variable can be set to a comma-separated list of
#       character set names.  GLib assumes that filenames are encoded in the
#       first character set from that list rather than in UTF-8.  The special
#       token "@locale" can be used to specify the character set for the
#       current locale.
#
# G_BROKEN_FILENAMES
#       If this environment variable is set, GLib assumes that filenames are
#       in the locale encoding rather than in UTF-8.

# If the LANG you have set contains any form of "UTF", we will guess you are
# using a UTF-8 locale.  Hopefully we're correct.
echo $LANG | grep -iq UTF
if ($status==0) then
  setenv G_FILENAME_ENCODING "@locale"
endif

# It doesn't hurt to export this since G_FILENAME_ENCODING takes priority
# over G_BROKEN_FILENAMES:
setenv G_BROKEN_FILENAMES 1

这是第二个,也给出了一个错误(qt4.csh):

#! /bin/csh
# Environment path variables for the Qt package:
if (! $?QT4DIR ) then

# It's best to use the generic directory to avoid
# compiling in a version-containing path:
if ( -d /usr/lib/qt ) then
    set path "QT4DIR /usr/lib/qt"
else
    # Find the newest Qt directory and set $QT4DIR to that:
    foreach qtd "/usr/lib/qt-*"
        if (-d $qtd ) then 
            setenv QT4DIR $qtd 
        endif
    end
endif
endif

set path = $path "$QT4DIR /bin"
if ( $?CPLUS_INCLUDE_PATH ) then
export CPLUS_INCLUDE_PATH $QT4DIR/include:$CPLUS_INCLUDE_PATH
else
export CPLUS_INCLUDE_PATH $QT4DIR/include
endif
exit

这些脚本似乎有与之关联的相应 Bourne shell 脚本,但我只从控制台收到错误,告诉我 .csh 文件有错误(文件意外结束)。当我启动控制台终端窗口时,没有任何关于 .sh 脚本的报告。

我是 Unix 脚本和 shell 编程的新手,我感觉在脚本前面的某个地方存在一些小的(对我而言)格式错误。

4

1 回答 1

0

#!/bin/csh这些脚本以而不是(更好的形式)开头,因此每次调用它们时它们#!/bin/csh -f总是会运行您自己的外壳启动文件(例如.cshrc,或在您的主目录中)。.tcshrc

由于两个不相关的脚本有错误,它们之间的共同点可能是您自己的点文件。首先添加-f到每个脚本的第一行,看看这是否解决了问题;然后在您自己的文件中查找语法错误。

于 2012-07-15T21:31:02.170 回答