Commit Graph

14687 Commits

Author SHA1 Message Date
ridiculousfish
04535e9701 Fix a few mild warnings with gcc 4.8 2021-05-10 16:49:01 -07:00
ridiculousfish
91a4059a8f Changelog fix for #7968 2021-05-10 16:03:33 -07:00
ridiculousfish
71df8f8622 Do not flock the uvars file on remote filesystems
In rare cases this may cause the universal variable file to drop
an update, if two happen at the same time and HOME is on an nfs mount.
But this is considered better than hanging if nfs is lockless.

Fixes #7968.
2021-05-10 15:24:32 -07:00
ridiculousfish
ba33b6dcc8 Mild refactoring of flock logic inside env_universal_t
This reorganizes the flock code in env_universal_t, removing a static
variable and making the behavior more explicit.
2021-05-10 15:23:57 -07:00
ridiculousfish
083f2698f9 Remove internal lock from env_universal_t
env_universal_t locking discipline is now managed by env.cpp.
That is, the shared instance of env_universal_t is managed by a lock.
We no longer need to have an internal lock, so remove it.
2021-05-10 15:23:57 -07:00
ridiculousfish
8d06357fbb Take advantage of empty uvars
Now that we allow uvars to be empty and uninitialized, we can always
instantiate it; we don't need to test whether it is null or not.
2021-05-10 15:23:56 -07:00
ridiculousfish
e2a1b25a24 Continue refactoring env_universal_t
Previously an instance of env_universal_t had to be created with a file
path. Switch to allowing it to be created as empty, and later initialized
with the file path. This will help simplify the case where universal
variables are not used; they may simply be not initialized and so just
appear empty.
2021-05-10 15:23:08 -07:00
ridiculousfish
16ba45fe64 Early work towards changing locking discipline of uvars
Rather than universal variables holding their own lock, we will wrap the
instance in a lock.
2021-05-10 14:23:07 -07:00
ridiculousfish
fa7402c415 Reorganize env_universal_t so that the public bits are at the top
No functional change here.
2021-05-10 14:23:07 -07:00
ridiculousfish
0d8cb0125a Remove the narrow_vars_path from universal variables
This was a cache of the wide vars_path, but it's not worth its
complexity.
2021-05-10 14:23:07 -07:00
ridiculousfish
6ab7945623 Mild refactoring of universal variables
This removes some unnecessary returns and other miscellaneous cleanup.
2021-05-10 14:23:07 -07:00
ridiculousfish
c8d909b2b2 Remove fd_check_is_remote
This function is no longer used; instead we detect if a given path is
remote, once, typically at startup.
2021-05-10 14:23:07 -07:00
ridiculousfish
1af441b4cc Do not lock the history file on remote filesystems
This avoids using locks for the history file if the file appears to be on
a remote file system, like NFS. This is to avoid hangs if the filesystem
does not support locking.

If locking is not enabled, then in rare cases, history items may be
dropped if multiple sessions try to write to the history file at once.
This is thought to be better than hanging. Hopefully the recent change to
require a trailing newline will avoid propagating partial items.
2021-05-10 14:23:07 -07:00
ridiculousfish
d1fd3d5825 Detect at startup whether config and data paths are remote
This is in preparation for changing the locking regime of history.
2021-05-10 14:23:07 -07:00
ridiculousfish
541e1d2fad base_directory_t to stop storing explicit success bool
This can be trivially computed from the error code.
2021-05-10 14:23:07 -07:00
ridiculousfish
f85f6a0127 Enforce that history items must end with trailing newlines
This helps prevent seeing partially written items from other sessions,
in preparation to reducing the amount of flocking done.
2021-05-10 14:23:07 -07:00
ripytide
8c19b6105f Not quite accurate code example heading 2021-05-10 19:28:06 +02:00
ripytide
40704ba7a2 Explanation of list range example wrong way round.
I'm assuming the first number before the **..** is the FROM and the number after it is the TO.
2021-05-10 17:01:12 +02:00
ridiculousfish
aa02cbd090 Wrap up history's mmap logic into its own type
This improves the factoring a bit.
2021-05-09 11:59:29 -07:00
ridiculousfish
d1befee19e Fix some potential leaks in history file contents
If history is corrupt and cannot be read, fish would return an error
without munmaping the file. Ensure it is properly munmapped.
2021-05-09 11:59:29 -07:00
ridiculousfish
c1f97c20b5 Pull in missing headers for MNT_LOCAL
fstatfs was only being used on Linux because MNT_LOCAL was not defined.
Pull in sys/mount.h and sys/param.h so macOS can see MNT_LOCAL.
2021-05-09 11:59:29 -07:00
ridiculousfish
37356fed44 Use wide printing when outputting debug categories
glibc doesn't like it when wide and narrow printing is mixed.
This fixes a strange beeping when running with debug enabled on glibc.
2021-05-09 11:59:29 -07:00
Fabian Homborg
aa84a4ba30 docs: Links for the function-related commands 2021-05-08 12:12:56 +02:00
ridiculousfish
555af37616 Disallow escaped characters in variable expansion
Prior to this fix, an escaped character like \x41 (hex for ascii A)
was interpreted the same was as A, so that $\x41 would be the same
as $A. Fix this by inserting an INTERNAL_SEPARATOR before these escapes,
so that we no longer treat it as part of the variable name.

This also affects brackets; don't treat echo $foo\1331\135 the same as
echo $foo[1].

Fixes #7969
2021-05-05 16:23:06 -07:00
ridiculousfish
3f35012afb Fix openssl completions for LibreSSL
Fixes #7966
2021-05-05 14:42:36 -07:00
ridiculousfish
f25b9f9831 Make the webconfig HTTP server threaded, fixing a Safari hang
Recently Safari seems to hang with fish webconfig. This is apparently
because Safari is opening a socket and not writing to it, causing
webconfig to hang until the timeout (30 seconds). It's not clear why.

Use ThreadingMixIn so that FishConfigTCPServer can handle more
than one connection at a time. This fixes the hang under Safari.
2021-05-05 13:29:55 -07:00
Johannes Altmanninger
fa74dc977b fish_greeting: show private mode message if $fish_greeting is empty list
This was droped because of Cartesian product expansion.
Also fix the spurious dot in case the greeting is "".

Fixes #7974
2021-05-05 18:53:51 +02:00
Cycatz
889ff25c75 Remove extra chars after -p and --load options 2021-05-05 21:45:16 +08:00
ridiculousfish
d338c45205 Fix a Sphinx warning
Add a newline to fix "Literal block ends without a blank line."
2021-05-04 13:50:09 -07:00
ridiculousfish
b823b91bcd Remove an errant newline from the dirs function
The dirs function prints an extra newline; it is not obvious why this is
needed but it has been this way forever. Let's remove it.
2021-05-04 13:32:21 -07:00
ridiculousfish
f0f10618df Improve the documentation for pushd
Correct the examples so that the directory stack is correct.
Fixes #7940
2021-05-04 13:21:46 -07:00
ridiculousfish
e0bf23ad26 Refactor the named pipe uvar notifier with a state machine
This attempts to simplify the named pipe notifier by switching to a state
machine model.
2021-05-04 11:59:12 -07:00
ridiculousfish
7c5b8b8556 Use the uvar notifier pipe timestamp to avoid excessive polling
In the named pipe notifier, notifications are broadcast by writing to the
pipe, waiting briefly, and then reading it back. When clients see the pipe
as readable, they report the uvars as potentially changed and fish will
sync against the uvar file.

Prior to this change, we synced repeatedly when the pipe was readable. But
we can do somewhat better by also checking the named pipe's timestamp (via
fstat). If the pipe has not changed, then we can skip the sync even if
there is currently data lingering on it.

With this change we should sync against the variable file less often
(typically once or twice per write); in the next change we refactor this
logic so it's easier to follow.
2021-05-04 11:59:12 -07:00
ridiculousfish
3a093e3ce8 Add a flog category for universal variable notifiers
Make it easier to debug this stuff.
2021-05-04 11:59:12 -07:00
ridiculousfish
8344289fac Give file_id_t a real constructor
Initialize it to invalid by default.
2021-05-04 11:59:12 -07:00
Fabian Homborg
c435d8b9b3 docs: Document enter/alt+enter harder
These were mentioned in "multiline editing", but not in the shared bindings
2021-05-04 20:00:46 +02:00
Fabian Homborg
d00576c9ea docs: More on join0 2021-05-04 14:14:27 +02:00
Fabian Homborg
d5f9fc84dc docs: Remove "note that"
It's one of my verbal tics, and I don't want it.
2021-05-03 18:39:54 +02:00
Fabian Homborg
1e13c60059 docs: Link relevant language sections from the tutorial
This allows us to keep the tutorial more focussed and leave the more
in-depth information in the "language" part of the documentation.
2021-05-03 18:15:24 +02:00
Fabian Homborg
0631bc509b Update copyright years
I hate this on principle, but as far as I know it has to be done.
2021-05-03 13:12:11 +02:00
Fabian Homborg
735105e33f bind tests: One more attempt to increase the timeouts
This is the last time I'm doing this before I rip these particular
tests out.

As far as I know there is no actual *problem* here, this is just
failing through a combination of macOS and Github Actions being slow
as molasses.

So it is wasting our time and therefore worse than not having these
tests at all, especially since they very rarely fail for good reasons.

We would leave some escape delay tests intact with generous timeouts, which would provide 90%
of the coverage with 10% of the hassle.
2021-05-03 12:13:18 +02:00
Fabian Homborg
8317b8bb8a Make ast FLOGs slightly less chatty
This removes the "did_visit" message because it doesn't really add
anything.

For example:

```
ast-construction: make job_list 0x55a6d19729f0
ast-construction: make job_conjunction 0x55a6d1971c00
ast-construction: will_visit job_conjunction 0x55a6d1971c00
ast-construction:   will_visit job 0x55a6d1971c18
ast-construction:     variable_assignment_list size: 0
ast-construction:     will_visit statement 0x55a6d1971c48
ast-construction:       make decorated_statement 0x55a6d1972650
ast-construction:       will_visit decorated_statement 0x55a6d1972650
ast-construction:         make argument_or_redirection 0x55a6d1968310
ast-construction:         will_visit argument_or_redirection 0x55a6d1968310
ast-construction:           make argument 0x55a6d197b0b0
ast-construction:         did_visit argument_or_redirection 0x55a6d1968310
ast-construction:         argument_or_redirection_list size: 1
ast-construction:       did_visit decorated_statement 0x55a6d1972650
ast-construction:     did_visit statement 0x55a6d1971c48
ast-construction:     job_continuation_list size: 0
ast-construction:   did_visit job 0x55a6d1971c18
ast-construction:   job_conjunction_continuation_list size: 0
ast-construction: did_visit job_conjunction 0x55a6d1971c00
ast-construction: job_list size: 1
```

those "did_visit" messages all correspond to "will_visit" ones. They
are effectively block delimiters like `end` or `}`.

If we remove them it turns into:

```
ast-construction: make job_list 0x55a6d19729f0
ast-construction: make job_conjunction 0x55a6d1971c00
ast-construction: will_visit job_conjunction 0x55a6d1971c00
ast-construction:   will_visit job 0x55a6d1971c18
ast-construction:     variable_assignment_list size: 0
ast-construction:     will_visit statement 0x55a6d1971c48
ast-construction:       make decorated_statement 0x55a6d1972650
ast-construction:       will_visit decorated_statement 0x55a6d1972650
ast-construction:         make argument_or_redirection 0x55a6d1968310
ast-construction:         will_visit argument_or_redirection 0x55a6d1968310
ast-construction:           make argument 0x55a6d197b0b0
ast-construction:         argument_or_redirection_list size: 1
ast-construction:     job_continuation_list size: 0
ast-construction:   job_conjunction_continuation_list size: 0
ast-construction: job_list size: 1
```

Which is still unambiguous because of the indentation.

(this is still *super verbose* and we might want to remove it from the
`*` "all" debug category and only allow turning it on explicitly)
2021-05-03 12:01:21 +02:00
Fabian Homborg
ae561c3702 bind tests: Sleep shorter, more often
We still wait 5s, but with higher resolution.

This allows that test to succeed within 100ms, instead of within 1s.
2021-05-03 11:26:41 +02:00
Fabian Homborg
d8c3d667d7 bind tests: More slack
As always, increase one escape delay and wait for a bit to enter
insert mode
2021-05-03 11:26:27 +02:00
ridiculousfish
0c79a8d3af Correct time.sleep to just sleep in bind.py
time was not imported, so this was raising an exception.
2021-05-02 11:25:33 -07:00
Fabian Homborg
202e5e53d5 Handle exit in keybindings immediately
This simply checks if the parser requested exit after running any
binding scripts (in read_normal_chars).

I think this means we no longer need the `exit` bind function.

Fixes #7967.
2021-05-02 20:27:08 +02:00
Johannes Altmanninger
28b17879c7 Install tmux to run tmux-tests on MacOS CI
Also install them explicitly on Linux, for better discoverability.
2021-05-01 22:51:35 +02:00
Johannes Altmanninger
c30a7cdfde Enable tmux-complete test in the CI
Just add some extra sleep time so it hopefully also works when the
CI system is overloaded. This succeeded >60 times in the CI, without
a single failure.

In case it legitimately fails again, we should provide simple steps
to reproduce the failure interactively (using "tmux attach").

The uvar issue only triggered because two fish are started - one is
running the tmux-complete script, the other one is running inside tmux.
We could reduce the complexity of this test by writing it in a
different language, like sh or python.
2021-05-01 22:51:35 +02:00
Johannes Altmanninger
b56b230076 Avoid excessive polling of universal variable file
Reproducible at least on Linux, where the "named pipe" universal
variable notifier is used:

	rm -rf build/test/xdg_config
	XDG_CONFIG_HOME=build/test/xdg_config ./build/fish -c "xterm -e ./build/fish"

The child fish reacts to keyboard input with a noticeable initial
delay.  This is because the universal variable file is polled over
a million times, even when I immediately press Control-D. This polling
prevents readb() from handling keyboard input.
Before commit 939aba02d ("Refactor input_common.cpp:readb"), readb()
reacted to keyboard input even when there were universal variable
notifications.  Restore this behavior, but make sure to call the
universal variable notifier after the new "prepare_to_select" logic.
Maybe the problem is in the notifier but the old behavior was sane.

Fixes the problems described in
7a556ec6f2 (commitcomment-49773677)

Adding "-d uvars-file" to the reproducesr shows that we are checking
the uvar file repeatedly:

	uvar-file: universal log sync
	uvar-file: universal log sync elided based on fast stat()
	uvar-file: universal log no modifications
2021-05-01 22:51:35 +02:00
Fabian Homborg
c55aa48308 Default colorscheme: Change pager prefix color for light terminals
From my checks (gnome-terminal with the "gnome light" colorscheme)
this seems to be the only color that's barely visible in a light
terminal, and it's the only color mentioned in both bug reports.

I'm leaving the artistic decisions to others, this is now *acceptable*
in both.

Note that, because we use universal variables here (hint #7317), this
will only be changed for preexisting installations when the user
reloads the colorscheme.

Fixes #3412
Fixes #3893
2021-05-01 20:16:23 +02:00