I use strace
to trace the behavior of a bash
process. The purpose is to find out the order bash
loads its configuration files.
I am running the following command under zsh
:
strace -e openat bash
After running this command, I end up in a new bash
shell, but I don't want that to happen. Is there any way to trace the bash
command without actually starting new bash
interactive shell?
I searched online but couldn't find anything. I was trying this with exec
: strace -e openat "$(exec bash)" 2>&1
, but still my shell changes to bash
from zsh
.
bash
shell, so naturally, you will be left inside an interactivebash
session (note: you do not log in again, only starting another shell session). If you want to exit that shell session, can't you just typeexit
?Ctrl+d
as well instead ofexit
but was curious if there is a way to trace without leavingzsh
itself.strace bash -c 'exit'
or similar, but since you want to investigate how that shell reads its startup files, you'd get a different result as what files are being read by default are different depending on if the shell is started as an interactive, non-interactive or login shell. This does sound a bit like an X-Y question. What is it you are trying to figure out by doing this? It strikes me that the order in which the shell reads its startup files is documented in the manual.zsh
process withexec
, you are not "leaving"zsh
. You are only starting another application (bash
) and you return to yourzsh
shell when the application has terminated.