bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bash can't find 'if' when evaluating PS1 following C-d


From: richl
Subject: Bash can't find 'if' when evaluating PS1 following C-d
Date: 21 May 2002 13:25:21 -0000

Configuration Information [Automatically generated, do not change]:
Machine: i386
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='i386' 
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='i386-redhat-linux-gnu' 
-DCONF_VENDOR='redhat' -DSHELL -DHAVE_CONFIG_H  -D_GNU_SOURCE 
-D_FILE_OFFSET_BITS=64  -I.  -I. -I./include -I./lib -I/usr/include -O2 
-march=i386 -mcpu=i686
uname output: Linux fishsticks.nssg.mitel.com 2.2.16-22 #1 Tue Aug 22 16:49:06 
EDT 2000 i686 unknown
Machine Type: i386-redhat-linux-gnu

Bash Version: 2.04
Patch Level: 11
Release Status: release

Description:
        I've got the following prompt in bash:
        
        ----8<---- cut here ----8<----
        PS1='$(tput bold)\w$(tput sgr0)\n'
        
        if [ "$TERM" = "xterm" -o "$TERM" = "xterm-color" -o \
             "$TERM" = "rxvt"  -o "$TERM" = "vs100" ]
          then
            PS1='\[\033]2;\u@\h: \w\007\033]1;\u@\h\007\]'
        fi
        
        PS1=$PS1':$(if [[ $? -eq 0 ]]
                then
                    echo ")"
                else
                    echo "("
                fi) $(if [[ _$USER = '_root' ]]
                then
                    echo $(tput bold)$USER$(tput sgr0)@
                elif [[ _$USER != _$ME ]]
                then
                    echo "$USER@"
                fi)\h\$ '
        
        if [ "$TERM" = "dockterm" ]
          then
            PS1='> '
        fi
        
        export PS1
        ----8<---- cut here ----8<----

        and I have IGNOREEOF=1 to require two ^D to exit an
        instance. When I press ^D the first time, I see:

        bash: if: command not found
        bash: command substitution: line 2: syntax error near unexpected token 
`then'
        bash: command substitution: line 2: `        then'
        bash: if: command not found
        bash: command substitution: line 2: syntax error near unexpected token 
`then'
        bash: command substitution: line 2: `        then'

        I'm not sure why bash can't find its builtin 'if' at that point,
        but I suspect it's not intended to happen. :-) ("Doctor, it hurts when
        I hit ^D!")
        
        I've also duplicated it on bash-2.05-8.

Repeat-By:
        As described above. A saner test case that produces the same
        sort of error:

        export PS1='$(if true; then true; fi)\w\$ '



reply via email to

[Prev in Thread] Current Thread [Next in Thread]