Commit Graph

16379 Commits

Author SHA1 Message Date
Mahmoud Al-Qudsi
3913b28153 Only retry failed pexpect tests under CI
A false negative while testing locally should be a rare thing, and individual
pexpect tests already take too long in case of a non-match making for a painful
edit-test loop.
2022-10-25 13:40:21 -05:00
Mahmoud Al-Qudsi
21599a49ea Make CALL_STACK_LIMIT_EXCEEDED_ERR_MSG more generic
We're now using this when a stack overflow is detected during eval/substitution
loops, too.
2022-10-25 13:40:21 -05:00
Mahmoud Al-Qudsi
175caab583 Prevent stack overflow from eval/substitution recursion
It seems to have originally been thought that the only possible way a stack
overflow could happen is via function calls, but there are other possibilities.

Issue #9302 reports how `eval` can be abused to recursively execute a string
substitution ad infinitum, triggering a stack overflow in fish.

This patch extends the stack overflow check to also check the current
`eval_level` against a new constant `FISH_MAX_EVAL_DEPTH`, currently set to a
conservative but hopefully still fair limit of 500. For future reference, with
the default stack size for the main/foreground thread of 8 MiB, we actually have
room for a stack depth around 2800, but that's only with extremely minimal state
stored in each stack frame.

I'm not entirely sure why we don't check `eval_depth` regardless of block type;
it can't be for performance reasons since it's just a simple integer comparison
- and a ridiculously easily one for the branch predictor handle, at that - but
maybe it's to try and support non-recursive nested execution blocks of greater
than `FISH_MAX_STACK_DEPTH`? But even without recursion, the stack can still
overflow so may be we should just bump the limit up some (to 500 like the new
`FISH_MAX_EVAL_DEPTH`?) and check it all the time?

Closes #9302.
2022-10-25 13:40:21 -05:00
Fabian Boehm
14ecb63e40
completions/usermod: Fix subu/gid option spelling
It's "subuid", not "sub-uid".

Fixes #9303
2022-10-25 11:09:41 +02:00
Mahmoud Al-Qudsi
e7bf98adc1 Make block_t moveable
The presence of the explicit constructor (even though it did nothing) prevented
the compiler from generating a move constructor for `block_t`.
2022-10-24 22:06:30 -05:00
Mahmoud Al-Qudsi
84b53b4cae Significantly reduce size of block_t
A `block_t` instance is allocated for each live block type in memory when
executing a script or snippet of fish code. While many of the items in a
`block_t` class are specific to a particular type of block, the overhead of
`maybe_t<event_t>` that's unused except in the relatively extremely rare case of
an event block is more significant than the rest, given that 88 out of the 216
bytes of a `block_t` are set aside for this field that is rarely used.

This patch reorders the `block_t` members by order of decreasing alignment,
bringing down the size to 208 bytes, then changes `maybe_t<event_t>` to
`shared_ptr<event_t>` instead of allocating room for the event on the stack.
This brings down the runtime memory size of a `block_t` to 136 bytes for a 37%
reduction in size.

I would like to investigate using inheritance and virtual methods to have a
`block_t` only include the values that actually make sense for the block rather
than always allocating some sort of storage for them and then only sometimes
using it. In addition to further reducing the memory, I think this could also be
a safer and saner approach overall, as it would make it very clear when and
where we can expect each block_type_type_t-dependent member to be present and
hold a value.
2022-10-24 21:04:17 -05:00
Mahmoud Al-Qudsi
44c9c51841 Disable leak detection in test_autosuggest_suggest_special() under CI
This is a false positive as a result of disabling TLS support in LSAN due to an
incompatibility with newer versions of glibc.

Also remove the older workaround (because it didn't work).
2022-10-24 19:02:49 -05:00
Mahmoud Al-Qudsi
bfa172852f Add a workaround for intermittent LSAN crash under CI
LSAN seems to have an issue with glibc's TLS functionality that causes it to
intermittently crash with SIGSEGV when run virtualized, as it is in our CI.

Relevant GitHub issues:
* https://github.com/google/sanitizers/issues/1342
* https://github.com/google/sanitizers/issues/1409
2022-10-24 18:56:55 -05:00
Mahmoud Al-Qudsi
4f8a7c4779 Drop LSAN CI options that break tests
LSAN with verbosity=1 or log_threads=1 adds output to stderr, breaking
littlecheck tests.
2022-10-24 18:56:55 -05:00
Mahmoud Al-Qudsi
de62091b03 Correctly set ASAN/UBSAN/LSAN options for CI
These are NOT build-time defines but rather run-time environment variables! They
have never had any effect and we have effectively never used them to affect
sanitizer behavior under CI with ASAN/UBSAN/LSAN enabled.

(I caught this because the tests don't pass with either of LSAN_OPTIONS
`verbosity=1` or `log_threads=1` because they inject text into the stderr
output, ensuring they never pass littlecheck.)
2022-10-24 18:56:55 -05:00
Mahmoud Al-Qudsi
63a2fdd773 Re-enable tests under ASAN/LSAN/UBSAN in GitHub CI
With the previous workaround skipping `test_autosuggest_suggest_special()` when
LSAN is enabled, the sanitizer seems to run to completion just fine.
2022-10-24 18:56:55 -05:00
Johannes Altmanninger
90b2c95bbc fish_clipboard_copy: bypass tmux, write OSC 52 to the underlying terminal
For security reasons, some terminals require explicit permission from the
user to interpret OSC 52. One of them is [tmux] but that one usually runs
inside another terminal. This means we can usually write directly to the
underlying terminal, bypassing tmux and the need for user configuration.

This only works if the underlying terminal is writable to the fish user,
which may not be the case if we switched user. For this reason, keep writing
to stdout as well, which should work fine if tmux is configured correctly.

[tmux]: https://github.com/tmux/tmux/wiki/Clipboard
2022-10-24 22:45:45 +02:00
Johannes Altmanninger
4de2891507 fish_clipboard_copy: make it work inside SSH/containers via OSC 52
When running inside SSH, Control-X runs a clipboard utility on the remote
system.  For pbcopy (and probably clip.exe too) this means that we write to the
remote system's clipboard. This is usually not what the user wants (although
it is consistent with  fish_clipboard_paste).  When X11 forwarding is used,
xclip/xsel copy to the SSH client's clipboard, which is what most users want.

When we don't have X11 forwarding, we need a different solution. Fortunately,
modern terminal emulators implement the OSC 52 escape sequence for setting
the clipboard of the terminal's system. Use it in fish_clipboard_copy.

Tested in SSH and Docker containers on foot, iTerm2, kitty, tmux and xterm
(this one requires "XTerm.vt100.allowWindowOps: true").

Should also work in GNU screen and Windows Terminal. On terminals that don't
support OSC 52 (like Gnome Terminal or Konsole), it seems to do nothing.

Since there does not seem to be a way to feature-probe OSC 52, let's just
always do both (pbcopy and friends as well as OSC 52).  In future, we should
probably stop calling pbpaste and clip.exe, at least on remote systems.

I think there is also an escape sequence to request pasting the system
clipboard but that's less important and less popular, possibly due to
security concerns.
2022-10-24 22:45:45 +02:00
Mahmoud Al-Qudsi
db0a297b8a Add new line between each trap -p output function
This makes the output a little easier on the eyes.
Tests appear to not need any changes to pass. I always forget whether or not
littlecheck cares about whitespace.
2022-10-24 15:36:02 -05:00
Mahmoud Al-Qudsi
07fc04465f Add regression test for trap -p 2022-10-24 15:36:02 -05:00
Mahmoud Al-Qudsi
c8f92878c3 Fix trap -p
Two different bugs completely broke `trap -p`. First bug broke filtering of
functions with trap handlers (`functions -na` prints functions separated by a
comma, not a new line). Second bug broke showing of function definitions for
traps because a refactor renamed only some call sites but references to `$i`
renamed.

These issues were introduced in a6820cbe and appear to have been caught just in
time: no released version is affected (changes made post-3.5.1).
2022-10-24 15:35:59 -05:00
Fabian Boehm
040591bc47 Actually explain what that macOS error is about
"Intermittent error has been fixed" tells me nothing.
2022-10-24 21:55:29 +02:00
Fabian Boehm
8d5198b9b4 fish_git_prompt: Fish show_upstream
This isn't a boolean option

Fixes #9301
2022-10-24 19:13:08 +02:00
ridiculousfish
74fd66fcbe Use -- before seq for negative numbers
busybox seq was complaining about the command:

    seq -550 -1

because it was trying to interpret -550 as a flag. Use -- to prevent
this.
2022-10-23 13:53:36 -07:00
ridiculousfish
c3274c3579 Fix up Dockerfiles
The Dockerfiles had bitrotted some.

Get them passing again, add libpcre2-dev where we can so we aren't
hitting more servers than necessary, and reformat the bionic files so
they can share more of the same image.
2022-10-23 13:53:36 -07:00
ridiculousfish
180acbbb27 Correct exit status of fish_run_tests.sh
fish_run_tests.sh was failing because its final command was a variable
test which was usually false. Switch to an if statement so the result is
true.
2022-10-23 13:53:36 -07:00
ridiculousfish
54a60d8dab Enable DOCKER_BUILDKIT
It just seems better without any major disadvantages.
2022-10-23 13:53:36 -07:00
Mahmoud Al-Qudsi
e3c67ae229 Reword debugging section in language docs
- Clean up the wording a little.
- Highlight the limitations of the "debugger" more clearly and don't mislead
  people into thinking it's possible to really interactively set/remove
  breakpoints except in select circumstances.

Sidenote: I can't believe we're using a markup language that doesn't support
nested inline markup. What a crying shame, rST!
2022-10-23 12:51:12 -05:00
Fabian Boehm
23b5390a0c docs: Mention --profile 2022-10-23 13:43:02 +02:00
Fabian Boehm
4001e2fe19 docs: Mention function name restriction in "identifiers" 2022-10-23 13:39:44 +02:00
Fabian Boehm
358214938a docs: Don't double-document --argument-names 2022-10-23 13:36:56 +02:00
Fabian Boehm
5ba9c7c2ca docs: Move event documentation to the events section
This was a bit awkward in the function page.
2022-10-23 11:39:13 +02:00
Aaron Gyes
9499582a8e
Update CHANGELOG.rst 2022-10-22 13:34:12 -07:00
Mahmoud Al-Qudsi
3f327dca79
Merge pull request #9295 from moverest/nvme-completions
Add `nvme` completions
2022-10-22 14:16:46 -05:00
Mahmoud Al-Qudsi
d0240e0fa0 fish_config: Pluralize $dir -> $dirs
It's a variable that holds all potential directories. The old name
makes it confusing to look at some of its usage sites and figure out
what is actually going on because they make no sense if $dir is only one
entry.
2022-10-22 13:23:44 -05:00
Mahmoud Al-Qudsi
5647f78953
Merge pull request #9273 from mqudsi/fish_theme_save
Fix `fish_config theme save` without trailing theme name. Fixes #9088.
2022-10-22 13:21:24 -05:00
Mahmoud Al-Qudsi
201a0d7319 Persist all color-like variables in fish_config theme save
Don't just save known color values but any values that could have been loaded
from a .theme file.

Also, refactor the theme variable name whitelist/filter in a shared "global"
variable so we never forget to update it at any of the individual use sites.
2022-10-22 13:20:12 -05:00
Mahmoud Al-Qudsi
22332b892d Fix fish_config theme save
The documentation states that running `fish_config theme save` after
`fish_config theme choose [theme_name]` will result in "saving" the
currently chosen theme, but this does not match the actual behavior of
`fish_config theme save` which expects a trailing argument specifying
the name of the theme to select/persist.

Given that the documented way has been included in a release and that it
makes more sense than calling `fish_config theme save xxx` when you are
*loading from* xxx and not *saving to* xxx, this patch revises
`fish_config.fish` to support the documented behavior.

When `fish_config theme save xxx` is used, xxx is loaded w/ its specified colors
saved to the according variables in the universal scope. But if `fish_config
theme save` is used without a theme's name specified, then the currently
specified (known) fish color variables are persisted from whatever scope they're
currently in (usually in the global scope from previewing a theme) to universal
variables of the same name.

This does *not* catch color variables unknown to fish! If a theme and a
prompt agree on some variable to hold some color but it's not a color variable
known to fish, it won't be persisted!

Closes #9088.
2022-10-22 13:19:59 -05:00
Clément Martinez
eeaf342426
Add nvme completions 2022-10-22 17:16:14 +01:00
Aaron Gyes
53cb3a98fc fish_apropos: manpath instead of man --path
On macOS Ventura, `man` does not take --path
2022-10-21 15:20:57 -07:00
Fabian Boehm
061f27a0bf CHANGELOG 2022-10-21 20:24:49 +02:00
Fabian Boehm
8c362c89b5
git prompt: Interpret values of "1", "yes" or "true" as true for bools instead of relying on defined-or-not (#9274)
This allows explicitly turning these settings off by setting the variable to e.g. 0.

See #7120
2022-10-21 20:22:20 +02:00
Rocka
f3372635fa completions: fix qdbus property completion 2022-10-21 18:30:54 +02:00
pagedown
ad55a55734 completions/unzip: Silence stderr 2022-10-21 18:29:14 +02:00
Fabian Boehm
a4dc6dcb74 docs: Add some more mentions
We should have more cross-linking and mentions of our builtins and
functions, so people can find the dang things.
2022-10-20 19:33:57 +02:00
Fabian Boehm
b6c1ecb288 docs: Add something on how we find commands 2022-10-20 19:31:18 +02:00
Mahmoud Al-Qudsi
a3ad5d6131
Add support for erasing in multiple scopes.
Allow erasing in multiple scopes in one go. Closes #7711.
2022-10-20 11:27:22 -05:00
Mahmoud Al-Qudsi
f122eb666b Changelog: Mention new set -eglU support 2022-10-20 11:21:42 -05:00
Mahmoud Al-Qudsi
994049d33b Document support for erasing from multiple scopes 2022-10-20 11:21:05 -05:00
Mahmoud Al-Qudsi
fb7f2d97e9 Add tests for erasing from multiple scopes 2022-10-20 11:21:05 -05:00
Mahmoud Al-Qudsi
fed64999bc Allow erasing in multiple scopes in one go 2022-10-20 11:21:05 -05:00
exploide
fa932533f2 completions john: redirect stderr to avoid errors 2022-10-19 20:17:58 +02:00
Fabian Boehm
b741decb07 CHANGELOG 2022-10-19 20:14:08 +02:00
Fabian Boehm
2419809a26 Fix formatting for isatty
(this did not recognize `[FILE DESC]` because of the space)
2022-10-19 20:10:26 +02:00
Fabian Boehm
98552817f5 Document fish_clipboard_copy/paste 2022-10-19 20:10:26 +02:00