Hi, guys!
I have written cpp aplication called MyShell that takes as the params some real shell name (generally bash) and its params. MyShell works as a wrapper for it.
I need to change command prompting for the inner shell, specifically the PS1 environmental variable.
I know how to do it command-line way using PS1 env var:
$ PS1="[myshell]"$PS1
[myshell]$
But it is not so easy to do that from cpp application:
string newPS1 = "[myshell]" + string(getenv("PS1"));
setenv("PS1", newPS1.c_str());
if (execvp(shell, argv) < 0) {
cerr << "can not exec " << shell << ": " << strerror(errno) << endl;
exit(1);
}
afaik, when bash is invoked it executes command from /etc/.bashrc or /etc/profile (depending on users options). Those scipts redefine PS1 var too. So my
setenv("PS1", newPS1.c_str());
has no effect.
Any suggestion?