bug-bash
[Top][All Lists]
Advanced

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

Re: TZ=... date affected PROMPT_COMMAND


From: Archimerged Ark Submedes
Subject: Re: TZ=... date affected PROMPT_COMMAND
Date: Thu, 17 Apr 2008 00:24:17 -0400

This version works the same as the more verbose one:

PROMPT_COMMAND='prompt_status=\ $?'
PS1=$SPECIAL_PS1"$my_color_on\A\${prompt_status# 0} \W\$$my_color_off "

Putting the variables inside $(...) avoids global variables and use of
PROMPT_COMMAND:

PS1='\A$(S=$?; W=$((S>99?4:(S>9?3:(S>0?2:0)))); printf "%*.d " $W $S)\W\$'
PS1=$SPECIAL_PS1"$my_color_on$PS1$my_color_off "

This works even if PROMPT_COMMAND is set, since PROMPT_COMMAND is not
"the most recently executed foreground pipeline," and does not change
the value of $?.

I claim this is a bash bug:  gcc is perfectly happy with S>99?4:S>9?3:S>0?2:0,
but GNU bash, version 3.2.33(1)-release (i386-redhat-linux-gnu) chokes on
W=$((S>99?4:S>9?3:S>0?2:0)).  The bash man page promises that "The  operators
and their precedence, associativity, and values are the same as in the
C language."




reply via email to

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