I want to switch to the bash shell from my custom shell in go.
I am not sure how to sleep my parent process (custom shell) and switch to the child process (bash)
This is my part of the code.
cmd := exec.Command("bash", "-c", "/bin/bash")
stdoutStderr, err := cmd.CombinedOutput()
if err != nil {
fmt.Printf(err.Error())
}
fmt.Printf("%s
", stdoutStderr)
I want to do it as follows:
myshell >> /bin/bash
$ /bin/myshell
myshell >>
the code is exec but not fork
binary, lookErr := exec.LookPath("/bin/bash")
if lookErr != nil {
panic(lookErr)
}
args := []string{"/bin/bash"}
env := os.Environ()
execErr := syscall.Exec(binary, args, env)
if execErr != nil {
panic(execErr)
}
so if I exit the bash shell, of course, my custom shell is killed.
myshell> bash
bash-3.2$ exit
exit