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


Groups > gnu.bash.bug > #14733 > unrolled thread

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

Started byGreg Wooledge <wooledg@eeg.ccf.org>
First post2018-10-23 12:06 -0400
Last post2018-10-23 12:06 -0400
Articles 1 — 1 participant

Back to article view | Back to gnu.bash.bug

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: Environment variable "PS4" can not be passed to bash script from version 4.2.46(2) Greg Wooledge <wooledg@eeg.ccf.org> - 2018-10-23 12:06 -0400

#14733 — Re: Environment variable "PS4" can not be passed to bash script from version 4.2.46(2)

FromGreg Wooledge <wooledg@eeg.ccf.org>
Date2018-10-23 12:06 -0400
SubjectRe: Environment variable "PS4" can not be passed to bash script from version 4.2.46(2)
Message-ID<mailman.2626.1540310808.1284.bug-bash@gnu.org>
On Tue, Oct 23, 2018 at 03:20:12PM +0000, Chen, Farrah wrote:
> But in Bash script, it cannot work, it keeps its original value:
> [root@fchen ~]# cat test.sh
> #!/usr/bin/bash
> echo $PS4
> echo $FAN

This is because you're doing it as root.  Bash strips PS4 from the
environment when started as root, as a security precaution.

wooledg:~$ PS4='hello' bash -c 'set -x; true'
hellotrue
wooledg:~$ sudo env PS4='hello' bash -c 'set -x; true'
[sudo] password for wooledg: 
+ true

Notice how it works as expected as a regular user, then "fails"
under sudo.

[toc] | [standalone]


Back to top | Article view | gnu.bash.bug


csiph-web