bug-bash
[Top][All Lists]
Advanced

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

Re: PATCH: Add \? to get PIPESTATUS information in the prompt


From: Paul Jarc
Subject: Re: PATCH: Add \? to get PIPESTATUS information in the prompt
Date: Thu, 06 Sep 2001 12:08:29 -0400
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/20.7

Chet Ramey <chet@nike.ins.cwru.edu> wrote:
> PROMPT_COMMAND=false
> true
> echo $?
>
> echos `0' for me, but I have no command substitutions in my prompt.

I get the same:
bash-2.04$ echo $PS1
\s-\v\$
bash-2.04$ PROMPT_COMMAND=false
bash-2.04$ true
bash-2.04$ echo $? $PIPESTATUS 
0 1

> The end result should be that neither $PROMPT_COMMAND nor prompt string
> expansion change $? or $PIPESTATUS.

Woohoo.  For now, my new prompt is:
hash_=
case "$(id)" in ('uid=0('*) hash_='#';; esac
function ps1 {
  local -a ps_=("$?" "${PIPESTATUS[@]}")
  local pwd_="$PWD" psstr_='' i_
  for i_ in "${ps_[@]}"; do psstr_="$psstr_$i_:"; done
  case "$psstr_" in
    (*[^0:]*) :;;
    (*) psstr_='';;
  esac
  [ "$hash_" = '' ] && pwd_="${pwd_/#$HOME/~}"
  echo -n "$hash_$psstr_${HOSTNAME%%.*}:${pwd_%/}/ "
  return "${ps_[0]}"
}
PS1='$(ps1)'


paul



reply via email to

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