I have created a shell script for both Bash and PowerShell that creates a python venv
, enters it, installs requirements and runs the django migrations and server, like so:
cd my-proj
python -m virtualenv venv
source venv/bin/activate #### .\venv\Scripts\activate FOR PS
pip install -r requirements.txt
python manage.py makemigrations
python manage.py migrate
python manage.py runserver
deactivate
cd ..
In Bash, when I stop the server with CTRL-C, the script will continue its execution, so it will correctly exit the venv
and return to the previous folder.
But not in PowerShell. In PS it will stop the whole script. I would like to safely stop the runserver
command by catching the CTRL-C. Is it possible?