I have a script launch.sh that executes itself as another user so as to create files with the correct owner. I want to pass -x to this invocation if it was originally passed to the scriptif [ `whoami` == deployuser ]; then  ... bunch of commands that need files to be created as deployuserelse  echo Respawning myself as the deployment user... #Inception  echo Called with: <$BASH_ARGV>, <$BASH_EXECUTION_STRING>, <$->  sudo -u deployuser -H bash $0 $@  # How to pass -x here if it was passed to the script initially?fiI've read the bash debugging page but there seems to be no clear option that tells whether the original script was launched with -x.
How can I tell if the currently executing bash script has been invoked with -x for debugging?
bash;debugging