I need to get the value of the PS1 variable inside a bash script.
I know that running the script with a dot before makes bash pass env variables to the script, but I need to get PS1 regardless of how it is invoked, since I don't trust who will run the script.
How do I get it?
Update:
the variable has been exported in /etc/profile, but I cannot get it:
[ Test ] root@myhost:~# export | grep PS1
declare -x PS1="[ Test ] \\u@\\h:\\w\\\$ "
[ Test ] root@myhost:~# cat test.sh
echo $PS1
[ Test ] root@myhost:~# bash test.sh
I get no output from the last command.