If you cd to some directory other than $HOME and run exec bash, the new bash starts in the working directory of the previous shell.
How does the new bash know what the previous working directory was?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It inherits its working directory just like every process inherits its parent’s working directory.
How do you think the
pwdprogram works? It just gets its own working directory with thegetcwdsystem call, which it inherited from its parent.