shell: move global variables before session setup
globals variable are now assigned before setting up the session so they are accessible in the session setup.
globals variable are now assigned before setting up the session so they are accessible in the session setup.