bug-bash
[Top][All Lists]
Advanced

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

print/echo lost from COMMAND_PROMPT Function


From: Manish Patel
Subject: print/echo lost from COMMAND_PROMPT Function
Date: Mon, 3 Feb 2020 15:26:34 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.0

Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
-DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
-DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash'
-DSHELL -DHAVE_CONFIG_H   -I.  -I../. -I.././include -I.././lib 
-Wdate-time -D_FORTIFY_SOURCE=2 -g -O2
-fdebug-prefix-map=/build/bash-N2nMjo/bash-4.4.18=.
-fstack-protector-strong -Wformat -Werror=format-security -Wall
-Wno-parentheses -Wno-format-security
uname output: Linux bsec-and-01 5.0.0-37-generic #40~18.04.1-Ubuntu SMP
Thu Nov 14 12:06:39 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu

Bash Version: 4.4
Patch Level: 20
Release Status: release

Description:
        Print/echo is lost when generated from a function in
COMMAND_PROMPT and placed in background in subshell.

I have embedded some git information in my command prompt.
However, due to large git data, it takes some time to calculate it all.
So I have placed
the git processing in the background function, which I call from
COMMAND_PROMPT.

Repeat-By:
        [Describe the sequence of events that causes the problem
        to occur.]
===== Test sourcing this file ========
# Below code works on bash-4.3.48(1)
# breaks on bash 4.4.20(1)

# When working I expect following behavior
# If I hit "ENTER" on command line, my prompt
# looks like:
# *[]$

# After some time when background processing is done, it updates as:
#  []$
#
# on Bash 4.4.20(1), prompt never updates. "*" never goes away.

PS1="*[]$"
PROMPT_COMMAND="setps"

long_process()
{
  # Here I do all my git processing (replacing with empty computing for
you to reproduce)
  cnt=1000
  while [ $cnt != 0 ]
  do
    ls -l > /dev/null
    (( cnt-- ))
  done
  tput sc
  echo -en "\r "
  tput rc
}
setps()
{
  (long_process &)
}
==========================

If I don't create a subshell, i.e. "long_process &"
I get annoying "Done" on bash 4.3:

[1]   Done                    long_process

But bash 4.4 simply stops it:

[1]+  Stopped                 long_process

Please help me with this.

Thank you
Manish.





reply via email to

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