I am writing a bash function that will run some commands to setup the environment and then leave the user at the prompt.I can runbash -c 'ls'To execute ls in bash.I can also dobash -c 'ls ; exec bash'To execute ls, and then leave a bash prompt open.However, I want to source a file and setup some aliases, functions, and environment variables and then leave the prompt open, so something like this: bash -c 'source env.sh ; exec bash'Of course, this doesn't work because subshells will not inherit aliases or functions. Is there a way around this problem? I'd prefer to still have the user's .bashrc be sourced, and not use the --init-file option.
How to run bash commands and leave prompt open?
bash
Set up an init file that will source the user's init file at the start, and then do whatever else you want:$ cat env.sh. ~/.bashrcexport SOMEVAR=valuesomespecialfunction() {  printf '%s\n' I'm so cool}$ bash --init-file env.sh