3

I have a very simple run.sh script which looks like this:

#!/bin/sh
echo "Hello, let's start!"
cd /Users/c/Dev/App/Code/
. venv/bin/activate
cd Backend
export FLASK_APP=app.py
export FLASK_DEBUG=1
export CONFIG=Local
flask run

After I run it, I get the following:

Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

Instead, I would like to get the active session as I would if I type the script manually, so simply the virtualenv active where I can then run pip install and see Flask's output.

How can I do that?

Costantin
  • 133
  • @pa4080 @karel @Eric-Carvalho @waltinator @Fabby: This question is not a duplicate of "Keep a program running in terminal". The question is about getting a active shell back after some program execution with additional environment settings (also typical for yocto). That cannot be accomplished by screen, background task or nohup – Simon Sudler Apr 13 '18 at 06:33

1 Answers1

3

If you want a active session after the script, don't run it, source it:

$ source ./run.sh
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

$

You can also start a new bash/sh session in your script and add the environment variables there. But that complicates things...

Simon Sudler
  • 3,931
  • 3
  • 21
  • 34
  • 1
    Note that if the sourced script exits (with exit or with options such as errexit), the shell you used to source the script will also exit. – Ikaros Apr 11 '18 at 14:48