Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #14732

Environment variable "PS4" can not be passed to bash script from version 4.2.46(2)

From "Chen, Farrah" <farrah.chen@intel.com>
Newsgroups gnu.bash.bug
Subject Environment variable "PS4" can not be passed to bash script from version 4.2.46(2)
Date 2018-10-23 15:20 +0000
Message-ID <mailman.2624.1540309964.1284.bug-bash@gnu.org> (permalink)

Show all headers | View raw


Hello,

I found a strange phenomenon, just as the subject, environment variable "PS4" cannot be passed to bash script, but any other variable, even self-defined variable can be passed to bash script.
My bash version is "GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu)", I downloaded an old version bash-2.0.tar.gz from ftp://ftp.gnu.org/gnu/bash/ and installed, no such issue found, "PS4" works well.

I tried to set PS4 in /etc/profile, in /etc/bashrc, and export PS4 in terminal, just like below, it is correct in current terminal, but cannot be passed to bash script.

export PS4='+[#$LINENO ${FUNCNAME[0]}() $BASH_SOURCE] '
export FAN='Myself'

Then source /etc/profile, /etc/bashrc, I also tried to reboot my machine.
In terminal, it works well:

[root@fchen ~]# echo $PS4
+[#$LINENO ${FUNCNAME[0]}() $BASH_SOURCE]
[root@fchen ~]# echo $FAN
Myself

But in Bash script, it cannot work, it keeps its original value:
[root@fchen ~]# cat test.sh
#!/usr/bin/bash
echo $PS4
echo $FAN

[root@fchen ~]# bash test.sh
bash test.sh
+
Myself

Value of variable "Fan" I set in /etc/profile is correct, but $PS4 keeps its original value.
I tried many different variable names, such as "PS3", "PS5", all of them work, except "PS4".

I found such problem when we update our os from Red-hat 7.3 to Red-hat 7.4,this is a long time ago.
Now, I know that on Red-Hat7.0, bash version 4.2.45(1)-release, no such problem; on Red-hat 7.5 bash version 4.2.46(2)-release, on Ubuntu 16.04 bash version 4.3.48(1)-release, both have this issue.
I assume this issue occurs after version 4.2.46.
PS4 is used by "set -x" to prefix tracing output, it is very useful for our work, but it doesn't work now, I'm confused.

Thanks a lot.


Thanks,
Fan

Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread


Thread

Environment variable "PS4" can not be passed to bash script from version 4.2.46(2) "Chen, Farrah" <farrah.chen@intel.com> - 2018-10-23 15:20 +0000

csiph-web