Why Does the Source Command Close My Terminal When No Argument is Provided?
Asked by
CuriousCat45
I'm working with a script called `venvs.sh` to manage virtual environments. It has a simple structure that checks for an environment name and sets one up if it doesn't exist. I also set up an alias in my `.bash_aliases` file to execute this script easily. Here's the issue: when I try to run the command `venv` without any parameters, my terminal closes unexpectedly. Is there a way to fix this so the terminal stays open?
Answers
Another thing to check is whether you have any additional settings in your terminal configuration that might be affecting how it responds to the `exit` command. But primarily, switching to `return` in your script should solve the issue!
Reply to this answer
You might want to replace the `exit 0` command in your script with `return` for cases where no environment name is given. The `exit` command will terminate the entire shell session, while `return` will just exit the function and keep your terminal open. Give it a try!
Reply to this answer
Add your answer
Answers are reviewed before publication.
Related Discussions