0

According to the Flask official tutorial:

Now, whenever you want to work on a project, you only have to activate the corresponding environment. On OS X and Linux, do the following:

$ . venv/bin/activate

This works. However, when I try running ./venv/bin/activate and venv/bin/activate, both gave me -bash: venv/bin/activate: Permission denied.

My question is: What does the . do?

1

2 Answers 2

3

The dot is, in this case, synonymous to the shell keyword source. What it does is to read the file and execute each line as if typed directly into the command line. Permission wise all you need is read access to the file.

Sourcing a file with shell commands is not the same as invoking a shell script: A shell script needs execute permission (this is why you got Permission denied) and will launch its own (non-interactive) shell.

1
  • can source substitute . in all cases?
    – trthfgh
    Commented Nov 16, 2017 at 13:02
1

The dot mean execute the scirpt in current shell. Normally shell scirpts are executed in subshell, but when you exit the scirpt you loose all the variables, set inside. This way (with dot) is how to keep the variables values, changed directories and so on.

3

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .