title: Run bash with redefined PS1 env variable
body: <p>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.</p>
  
  <p>I need to change command prompting for the inner shell, specifically the PS1 environmental variable.</p>
  
  <p>I know how to do it command-line way using PS1 env var:</p>
  
  <pre><code>$ PS1="[myshell]"$PS1
  
  [myshell]$ 
  </code></pre>
  
  <p>But it is not so easy to do that from cpp application:</p>
  
  <pre><code>string newPS1 = "[myshell]" + string(getenv("PS1"));
  setenv("PS1", newPS1.c_str());
  if (execvp(shell, argv) &lt; 0) {
      cerr &lt;&lt; "can not exec " &lt;&lt; shell &lt;&lt; ": " &lt;&lt; strerror(errno) &lt;&lt; endl;
      exit(1);
  }
  </code></pre>
  
  <p>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  </p>
  
  <pre><code>setenv("PS1", newPS1.c_str());
  </code></pre>
  
  <p>has no effect.</p>
  
  <p>Any suggestion?</p>