c++ - Run bash with redefined PS1 env variable -
I have written the CPP application, named MyShell, which takes the form of a parameter, some actual shell names (usually Bash) and its parameters. MyShell works as a cover for it.
I need to open the internal shell, especially for PS1 environment variables.
I know how to use it in a command line way PS1 env var: $ PS1 = "[myshell]" $ PS1 [myshell] $
but it is not so easy from CPP:
string npeps 1 = "[meshled]" + string (getenv ("PS1")); Setenby ("PS1", NPS 1Cestrate ()); If (execvp (shell, argv) <0} {cerr & lt; & Lt; "Can not do" & lt; & Lt; Opening & lt; & Lt; ":" & Lt; & Lt; Strerror (error) & lt; & Lt; Endl; Exit (1); }
afaik, when bash is applied, it executes commands from /etc/.bashrc or / etc / profile (depending on the options of users). If I redefined the PS1 var then my
Settainment ("PS1", newPS1.c_str ()); >
If you just want to change the signal from the default settings, then you export PS1 = "[myshell] "$ PS1
to ~ / .bashrc
or edit
if you change the original If you do not want to, press it before launching your CPU and hold it down. ~ / .bashrc
file You can invoice:
bash --rcfile / tmp / myCustomPS1
with / Tmp / myCustomPS1
:
if [-f ~ / .bashrc] then. ~ / .bashrc fi Export PS1 = "[myshell]" $ PS1
Comments
Post a Comment