fish-shell/doc_src
Fabian Homborg e1d19cf571 Don't touch $SHLVL if not interactive
It's not super clear what $SHLVL is useful for, but the current
definition is essentially
"number of shells in the parent processes + 1"

which isn't *super useful*?

Bash's behavior here is a bit weird in that it increments $SHLVL
basically always, but since it auto-execs the last process it will
decrement it again, so in practice it's often not incremented.

E.g.

```
> echo $SHLVL
1
> bash -c 'echo $SHLVL; bash'
2
>> echo $SHLVL
2
```

Both bashes here end up having the same $SHLVL because this is
equivalent to `echo $SHLVL; exec bash`. Running `echo $SHLVL` and then
`bash -c 'echo $SHLVL'` in an interactive bash will have a different
result (1 and 2) because that doesn't *exec* the inner bash.

That's not something we want to get into, so what we do is increment
$SHLVL in every interactive fish. Non-interactive fish will simply
import the existing value.

That means if you had e.g. a bash that runs a fish script that ends up
opening a new fish session, you would have a $SHLVL of *2* - one for the
bash, and one for the inner fish.

We key this off is_interactive_session() (which can also be enabled
via `fish -i`) because it's easy and because `fish -i` is asking for
fish to be, in some form, "interactive".

That means most of the time $SHLVL will be "how many shells am I deep,
how often do I have to `exit`", except for when you specifically asked
for a fish to be "interactive". If that's a problem, we can rethink it.

Fixes #7864.
2021-03-29 17:44:13 +02:00
..
cmds Add max and min math functions 2021-03-28 13:22:44 -07:00
python_docs_theme docs: Give logo a specific width 2021-03-02 17:03:32 +01:00
commands.rst We no longer have two doc systems, move sphinx_doc_src back to doc_src 2020-02-19 17:00:35 -08:00
completions.rst docs: Replace all internal links with :ref:s 2021-03-26 19:32:14 +01:00
conf.py Split up documentation 2021-03-27 15:44:17 +01:00
design.rst Make rationale spacing consistent 2020-10-12 20:25:35 +02:00
faq.rst faq: Reword ssh question 2021-03-08 22:28:26 +01:00
fish_for_bash_users.rst Fish for bash users: Fix missing word and link it from index 2021-01-22 16:23:09 +01:00
fish_indent_lexer.py Highlight keywords differently 2021-02-07 21:18:51 +01:00
index.rst Split up documentation 2021-03-27 15:44:17 +01:00
interactive.rst Split up documentation 2021-03-27 15:44:17 +01:00
language.rst Don't touch $SHLVL if not interactive 2021-03-29 17:44:13 +02:00
license.rst Add docs theme license 2020-10-04 14:51:05 +02:00
relnotes.rst docs: call the CHANGELOG "release notes" 2021-02-25 22:46:24 +08:00
tutorial.rst docs: Replace all internal links with :ref:s 2021-03-26 19:32:14 +01:00