2017-05-04 16 views
0

**下面是etc profile如何恢復配置文件我得到的錯誤是在ubuntu的etc/profile文件的意外結束在Ubuntu的etc/profile文件的意外結束

在此先感謝。 **

# /etc/profile: system-wide .profile file for the Bourne shell (sh(1)) 
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...). 

if [ "$PS1" ]; then 
    if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then 
    # The file bash.bashrc already sets the default PS1. 
    # PS1='\h:\w\$ ' 
    if [ -f /etc/bash.bashrc ]; then 
     . /etc/bash.bashrc 
    fi 
    else 
    if [ "`id -u`" -eq 0 ]; then 
     PS1='# ' 
    else 
     PS1='$ ' 
    fi 
    fi 


# The default umask is now handled by pam_umask. 
# See pam_umask(8) and /etc/login.defs. 

if [ -d /etc/profile.d ]; then 
    for i in /etc/profile.d/*.sh; do 
    if [ -r $i ]; then 
     . $i 
    fi 
    done 
    unset i 
fi 

回答

0

你缺少在第一塊主要if一個fi

if [ "$PS1" ]; then                                       
    if [ "$BASH" ] && [ "$BASH" != "/bin/sh" ]; then 
     # The file bash.bashrc already sets the default PS1. 
     # PS1='\h:\w\$ ' 
     if [ -f /etc/bash.bashrc ]; then 
      . /etc/bash.bashrc 
     fi 
    else 
     if [ `id -u` -eq 0 ]; then 
      PS1='# ' 
     else 
      PS1='$ ' 
     fi 
    fi 
fi 

當您比較([ `id -u` -eq 0 ]),在比較的兩邊雙引號不要用引號無論使用變量或都沒有。如果您在一側使用報價,而不是在另一側使用報價,則會將數字與字符串進行比較。