bug-bash
[Top][All Lists]
Advanced

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

possible bash 4.0.10 bug: command substitution in PROMPT_COMMAND


From: Jared Yanovich
Subject: possible bash 4.0.10 bug: command substitution in PROMPT_COMMAND
Date: Thu, 9 Apr 2009 17:12:13 -0400

Hi, I upgraded to bash 4.0.10 and my PS1 prompt is no longer displaying
anything at all.  Here is a contrived .bashrc:

 .bashrc:
  ------------------------ BEGIN
  f()
  {
        $(:)
        PS1='$ '
  }
  PROMPT_COMMAND=f
  ------------------------ END

However, it works if I take the command substitution sequence `$(...)'
out.  Things get ever weirder if I try changing it on the command line:

  -bash-4.0$ f() { PS1='$ '; echo foo; }; PROMPT_COMMAND=f
  foo
  $

This works as expected, but if I use a command substitution this time:

  -bash-4.0$ f() { PS1='$ '; echo foo; $(:); }; PROMPT_COMMAND=f
  foo
  -bash-4.0$

My prompt didn't change.  In fact, setting PS1 after this point in the
shell doesn't work at all until you 'unset PROMPT_COMMAND', at which
point PS1 will finally take on the value assigned by the PROMPT_COMMAND.

Further, if I put the command substitution inside a subshell, it does
work:

  -bash-4.0$ f() { PS1='$ '; echo foo; ($(:)); }; PROMPT_COMMAND=f
  foo
  $

I have not tried the newer patch levels above 4.0.10, so sorry if this
has already been fixed, but I looked up to 4.0.15 briefly and did not
notice this address being addressed directly.

Specifically, I use this output of a command in my prompt (sorry to
offend anyone who finds that ridiculous), so it would be nice to have
the old functionality back if possible.

Thanks!




reply via email to

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