首页 新闻 会员 周边 捐助

linux配置java环境报错-bash: /etc/profile: line 77: syntax error: unexpected end of file

0
悬赏园豆:120 [已解决问题] 解决于 2020-04-03 22:28

配置java环境时 不小心动了etc/profile 里的东西,提示以下错误,大神能帮我看看嘛,┭┮﹏┭┮
-bash: /etc/profile: line 70: unexpected EOF while looking for matching `"'
-bash: /etc/profile: line 77: syntax error: unexpected end of file
[root@izuf6fyls0jsr430b2tdr3z ~]# cat -v /etc/profile

/etc/profile

System wide environment and startup programs, for login setup

Functions and aliases go in /etc/bashrc

It's NOT a good idea to change this file unless you know what you

are doing. It's much better to create a custom.sh shell script in

/etc/profile.d/ to make custom changes to your environment, as this

will prevent the need for merging in future updates.

pathmunge () {
case "😒{PATH}:" in
:"$1":)
;;
*)
if [ "$2" = "after" ] ; then
PATH=$PATH:$1
else
PATH=$1:$PATH
fi
esac
}

if [ -x /usr/bin/id ]; then
if [ -z "$EUID" ]; then
# ksh workaround
EUID=id -u
UID=id -ru
fi

USER="'ID-un'"
LOGNAME=$USER
MAIL="/var/spool/mail/$USER

fi

Path manipulation

if [ "$EUID" = "0" ]; then
pathmunge /usr/sbin
pathmunge /usr/local/sbin
else
pathmunge /usr/local/sbin after
pathmunge /usr/sbin after
fi

HOSTNAME='/usr/bin/hostname 2>/dev/null'
HISTSIZE=1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL=ignoreboth
else
export HISTCONTROL=ignoredups
fi

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

By default, we want umask to get set. This sets it for login shell

Current threshold for system reserved uid/gids is 200

You could check uidgid reservation validity in

/usr/share/doc/setup-*/uidgid file

if [ $UID -gt 199 ] && [ "id -gn" = "id -un" ]; then
umask 002
else
umask 022
fi

for i in /etc/profile.d/.sh ; do
if [ -r "$i" ]; then
if [ "${-#
i}" != "$-" ]; then
. "$i"
else
. "$i" >/dev/null
fi
fi
done

unset i
unset -f pathmunge

凡尘26222的主页 凡尘26222 | 初学一级 | 园豆:6
提问于:2020-04-03 21:33
< >
分享
最佳答案
0

能把代码好好粘贴一下吗?

收获园豆:120
wengle | 小虾三级 |园豆:567 | 2020-04-03 21:45

我从电脑粘贴过来就变成这个样子呢,我也不想,新手,还不能上传截图照片

凡尘26222 | 园豆:6 (初学一级) | 2020-04-03 21:48

我看到 也很奇怪 我重新修改问题重新粘贴还是这样子的

凡尘26222 | 园豆:6 (初学一级) | 2020-04-03 21:49

@凡尘26222: 可以使用markdown的代码块,试试看

wengle | 园豆:567 (小虾三级) | 2020-04-03 21:55

@凡尘26222: MAIL="/var/spool/mail/$USER 应该是这里的最后少了一个",应该是:MAIL="/var/spool/mail/$USER"

wengle | 园豆:567 (小虾三级) | 2020-04-03 22:02

@凡尘26222: 如有帮助,请采纳~~, 谢谢 😄

wengle | 园豆:567 (小虾三级) | 2020-04-03 22:04

@wengle: 棒棒哒,么么哒

凡尘26222 | 园豆:6 (初学一级) | 2020-04-03 22:23

@wengle: 解决呢,开心,好的,马上采纳,再问你一个问题,为什么它提示的是第70行,可这句不是第70行啊

凡尘26222 | 园豆:6 (初学一级) | 2020-04-03 22:26

@凡尘26222: 这个跟shell的字符串解析有关系,可以参考一个简单的例子,来理解这个问题:

#!/usr/bin/env bash

abc="123"

echo "/home/$abc

echo "hello"

sh unexpected.sh

unexpected.sh: line 7: unexpected EOF while looking for matching `"'
unexpected.sh: line 8: syntax error: unexpected end of file

改为:

#!/usr/bin/env bash

abc="123"

echo "/home/$abc
world"

echo "hello"

sh unexpected.sh

/home/123
world
hello

shell解析字符串是从"开始,一直到下一个最近的",这个之间的都是字符串

wengle | 园豆:567 (小虾三级) | 2020-04-03 22:34
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册