配置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
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
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
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: 可以使用markdown的代码块,试试看
@凡尘26222: MAIL="/var/spool/mail/$USER
应该是这里的最后少了一个",应该是:MAIL="/var/spool/mail/$USER"
@凡尘26222: 如有帮助,请采纳~~, 谢谢 😄
@wengle: 棒棒哒,么么哒
@wengle: 解决呢,开心,好的,马上采纳,再问你一个问题,为什么它提示的是第70行,可这句不是第70行啊
@凡尘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解析字符串是从"开始,一直到下一个最近的",这个之间的都是字符串