fish-shell/tests
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
..
checks Don't touch $SHLVL if not interactive 2021-03-29 17:44:13 +02:00
pexpects Restore terminal modes after running key bindings with external commands 2021-03-10 22:36:33 -08:00
test_functions Resurrect one last function 2020-03-17 21:58:49 +01:00
.gitignore tweak gitignore rules for *tests* directory 2017-02-20 20:29:43 -08:00
history_sample_bash history: Improve bash import check 2021-03-28 20:30:37 +02:00
history_sample_corrupt1 Improve history robustness against corrupt files 2014-07-29 14:42:03 -07:00
history_sample_fish_1_x Support for importing fish 1.x's history and format, and also bash 2012-06-15 16:24:05 -07:00
history_sample_fish_2_0 Support for importing fish 1.x's history and format, and also bash 2012-06-15 16:24:05 -07:00
interactive.config Remove some unused functions from the test harness 2020-11-15 09:17:23 +01:00
interactive.fish Allow to run individual interactive tests by setting FISH_PEXPECT_FILES 2021-01-07 17:09:05 +01:00
test_util.fish tests: Remove unused colordiff function 2021-01-01 14:18:17 +01:00
test.fish Cleanup test setup a bit 2020-11-15 09:17:23 +01:00