Linux getenv() could not get $PS1 or $PS2
c, environment-variables, linux, shell
Solution
The `PS1` and `PS2` shell variables are not exported and are therefore inaccessible from child processes. You can test this with a simple script:
$ cat /tmp/pstest.sh
#!/bin/sh
echo PS1=$PS1
echo PS2=$PS2
$ /tmp/pstest.sh
PS1=
PS2=
Problem
My home world is to write a shell. and I must use `$PS2`. but when I write a code like this: ``` char *ENV_ps2; ENV_ps2 = getenv("PS2"); ``` I just found `ENV_ps2` was point to `(null)`. how could I get the `$PS2` in my program ?