Commit Graph

20428 Commits

Author SHA1 Message Date
exploide
fb314b28ff completions(tcpdump): suppress stderr + updates 2025-04-18 17:17:39 +02:00
Daniel Rainer
aa01f984b7 Use File as arg to print_profile 2025-04-17 11:46:35 +02:00
Daniel Rainer
b8bd3a25d7 Improve error handling 2025-04-17 11:46:35 +02:00
Daniel Rainer
01e7ba4b3a Reduce scope of raw_fd 2025-04-17 11:46:35 +02:00
Daniel Rainer
e5c953ea92 Replace read_loop with more idiomatic code 2025-04-17 11:46:35 +02:00
Daniel Rainer
70d682a110 Set file permissions via stdlib method 2025-04-17 11:46:35 +02:00
Daniel Rainer
21e284e548 Rename last_read_file to last_read_file_id
This is done to match the field's type.
2025-04-17 11:46:35 +02:00
Daniel Rainer
c2b8ee5554 Replace fstat with File::metadata() where possible 2025-04-17 11:46:35 +02:00
Daniel Rainer
5e8276ed15 Change file_id_for_fd to file_id_for_file 2025-04-17 11:46:35 +02:00
Johannes Altmanninger
4e85366416 builtin commandline: minor cleanup 2025-04-16 11:24:33 +02:00
Johannes Altmanninger
0284292392 builtin read to pass through invalid UTF-8; reader to ignore invalid codepoints
Two issues:

1. typing the codepoint 0x123456 into fish_key_reader:

	$ fish_key_reader -cV
	# decoded from: \xf4\xa3\x91
	bind \xf4 'do something'
	# decoded from: 
	bind \xa3 'do something'
	# decoded from: 
	bind \x91 'do something'

The invalid codepoint is represented in its original encoding, which leaks
to the UI. This was more or less intentionally added by b77d1d0e2b (Stop
crashing on invalid Unicode input, 2024-02-27).  That commit rendered it
as replacement byte, but that was removed for other reasons in e25a1358e6
(Work around broken rendering of pasted multibyte chars in non-UTF-8-ish
locale, 2024-08-03).

We no longer insert such (PUA) codepoints into the commandline.  The "bind"
comes above would work however.  I don't think this is something we want
to support.  Discard invalid codepoints in the reader, so they can't be
bound and fish_key_reader shows nothing.

2. builtin read silently drops invalid encodings This builtin is not really
suited to read binary data (#11383 is an error scenario), but I guess it can
be bent to do that.  Some of its code paths use str2wcstring which passes
through e.g. invalid UTF-8.  The read-one-char-at-a-time code path doesn't.
Fix this.
2025-04-16 11:24:33 +02:00
Johannes Altmanninger
d9ba27f58f builtin read: always handle out-of-range codepoints (Rust port regression)
As mentioned in
https://github.com/fish-shell/fish-shell/pull/9688#discussion_r1155089596,
commit b77d1d0e2b (Stop crashing on invalid Unicode input, 2024-02-27), Rust's
char type doesn't support arbitrary 32-bit values.  Out-of-range Unicode
codepoints would cause crashes.  That commit addressed this by converting
the encoded bytes (e.g. UTF-8) to special private-use-area characters that
fish knows about.  It didn't bother to update the code path in builtin read
that relies on mbrtowc as well.

Fix that. Move and rename parse_codepoint() and rename/reorder its input/output
parameters.

Note that the behavior is still wrong if builtin read can't decode the
input; see the next commit.

Fixes #11383
2025-04-16 11:24:33 +02:00
Johannes Altmanninger
b061178606 Reduce parse_codepoint responsibilities, fixing alt in single-byte locale?
This also changes the single-byte locale code path to treat keyboard input
like "\x1ba" as alt-a instead of "escape,a".  I can't off-hand reproduce
a problem with "LC_ALL=C fish_key_reader", I guess we always use a UTF-8
locale if available?
2025-04-16 11:24:33 +02:00
Johannes Altmanninger
a63633edea Remove redundant code in parse_codepoint 2025-04-16 11:24:33 +02:00
Johannes Altmanninger
c740c656a8 Fix builtin test assigning wrong range to "! -d /" (Rust port regression)
Fixes #11387
2025-04-16 11:24:33 +02:00
Johannes Altmanninger
721c9a2c14 completions/set: add some special variables 2025-04-16 11:24:33 +02:00
Johannes Altmanninger
7337bfee47 completions/set: sort 2025-04-16 11:24:33 +02:00
Johannes Altmanninger
5076cfbd71 Fix a case where path canonicalization leaks trailing slash
As reported in
https://matrix.to/#/!YLTeaulxSDauOOxBoR:matrix.org/$BDVmBtBgtKCj45dVfS36rP7Y6Fo7E4uBg1vcH9IIIQg

	tmux new-session -c "" fish -C 'echo $PWD'

prints

	/home/fishuser/

This is because our path canonicalization function only
removes trailing slashes if there were duplicate slashes in the string.
Else (for the case above), we end up with "trailing == len"
which means we ignore trailing slashes.

I don't think this was intended by 24f1da7f30 (Add a fancy new
paths_are_equivalent function to test for equivalent paths instead of merely
equal ones, 2013-08-27). Fix it.
2025-04-16 11:24:33 +02:00
Johannes Altmanninger
2d506245be Rename confusing variables in path_make_canonical
The terms leading/trailing for the read-head and write-head are reasonable
but confusing in this context where trailing (slash) has another meaning.
2025-04-16 11:24:33 +02:00
Johannes Altmanninger
afa517d907 doc/terminal-compatibility: document cursor shaping sequence
While at it, also document the command to reset the shape to the default,
which we should probably use.  See foot commit 49034bb7 (csi: let CSI 0 q mean
"switch to user configured cursor style", 2019-07-22).

As of today, the XTerm documentation is a not clear on this; in
XTerm itself, CSI 0 q may actually change the cursor because they have an
additional default cursor is configured differently..
2025-04-16 11:24:33 +02:00
Johannes Altmanninger
123b262e97 fish_jj_prompt: remove not-so-useful bits
Things like branch and tag name can take up a lot of space on the screen. The
empty status may be useful but we're still looking for evidence.  For now let's
keep only the conflict status, which is fairly familiar from the Git prompt.

See also #11183
2025-04-16 11:24:33 +02:00
Johannes Altmanninger
267b16235d Fix transient prompt mode for single-line prompts
Extend a hack multi-line prompts to the new transient prompt code path.
This fixes transient prompt with single-line prompts; added a test case.

While at it, add a test that covers the need for this hack.

Patch-by: kerty <g.kabakov@inbox.ru>

See https://github.com/fish-shell/fish-shell/pull/11153#issuecomment-2801014723
2025-04-16 11:22:14 +02:00
Ilya Grigoriev
76a6ffe59e status get/list-files: fix minor bugs when compiled without embedded files (#11390)
* man: redirect stderr to /dev/null when checking for embedded files

This fixes a bug where `man status` results in "status: fish was not
built with embedded files⏎" printed.

* fish_config and status completions: redirect stderr to /dev/null when checking for embedded files

I am less sure about this commit, can get rid of it.

* status get-file/list-files: add \n to error message when not compiled with embedded files
2025-04-16 08:46:22 +02:00
Fabian Boehm
6ede047680 completions/cargo: Fix package completion
The original only worked in the manifest directory *and* didn't even
list the right packages.

E.g. for fish it listed "printf", when the package is called
"fish-printf". So we're not keeping it because it's wrong.

Instead let's parse the actual json. It's a shame there is no
simple command to just get it line-delimited, of course.

Fixes #11384
2025-04-15 20:23:03 +02:00
Fabian Boehm
ab7d52d727 completions/rustup: Simplify listing installable targets 2025-04-15 20:21:10 +02:00
Fabian Boehm
6c75cf75fe Update widestring 2025-04-15 20:13:22 +02:00
ndrew222
827bc32561 added completion for uv and uvx 2025-04-16 00:36:42 +08:00
Peter Ammon
85ea9eefc6 Fight off some clipplies 2025-04-14 21:08:26 -07:00
David Adam
692b53ab85 remove stray file 2025-04-13 09:14:46 +08:00
Johannes Altmanninger
92510c0488 man.fish: fix spurious error on embed-data builds
Commands like "man grep" print an error because __fish_data_dir[1] is no
longer defined. Fix that.
2025-04-12 20:25:08 +02:00
Fabian Boehm
765b700a04 cmake: Warn on unknown build type
CMake has this entire zoo of weird build types including "MinSizeRel".
I've also seen it set to empty, in distro packages no less.

Since we can't really make them all known to cargo, let's warn.

We could also error, but I'm not convinced there isn't some distro
packager out there setting it to "StrawberriesAndKittens" for some
reason,
and they'd be very cross with us if that stopped working.

See #11376
2025-04-12 14:21:56 +02:00
Johannes Altmanninger
b569f0d62f Update docs for transient prompt
Closes #11153
2025-04-12 12:09:08 +02:00
Johannes Altmanninger
6e85e5f6a0 Fix sphinx warning in changelog 2025-04-12 12:07:54 +02:00
Johannes Altmanninger
4b2c707721 Simplify exec_prompt_cmd 2025-04-12 12:07:54 +02:00
kerty
b3e417fd05 Add documentation for transient prompt 2025-04-12 12:07:26 +02:00
kerty
231ab22ce4 Update docs for transient prompt
See #11153
2025-04-12 12:07:26 +02:00
kerty
ca1d7ef863 Fix residual lines after repaint with shrinking prompt
If you use `set t 10; function fish_prompt; seq $t; set t $(math $t - 1); end` and trigger a repaint, you will see 9 residual lines from the previous prompt.
2025-04-12 10:51:35 +02:00
kerty
7ed4dfbd2d Ease condition for the execution of the right prompt
Now, the right prompt will not be executed only if it is undefined `fish_right_prompt`.
This allows the use of `read -p 'echo left' -R 'echo right'`.

Also changes condition for use of `DEFAULT_PROMPT` for consistency.
2025-04-12 10:46:33 +02:00
kerty
cb31f3e092 Refactor Reader::exec_prompt
Also fixes repaint-mode being run interactively
2025-04-12 10:46:33 +02:00
Johannes Altmanninger
b81a55e5f0 Fix bad conflict resolution 2025-04-12 10:34:38 +02:00
Johannes Altmanninger
6fcb418ae3 Enable 24-bit RGB colors by default
I think `set_color ff0000` should default to outputting true-color sequences.
Unfortunately there is no good and widely-supported way to query for true-color
support.  `COLORTERM=truecolor` doesn't work in some cases such as ssh.

Since many terminals nowadays implement the RGB sequences, let's try using
them by default.

Note that Emacs's ansi-term implements truecolor now.

See also the discussion around
https://github.com/fish-shell/fish-shell/pull/11345#issuecomment-2794920900

Closes #11372
2025-04-11 22:20:45 +02:00
Johannes Altmanninger
e7270915ac Update color support on COLORTERM change 2025-04-11 22:20:45 +02:00
Johannes Altmanninger
e45401e403 Fix copy paste error for smso/ritm/rmul sequences
We have basically zero system tests for text coloring/formatting.  I have
something in the works that will enable this without forcing tests to parse
the output of "tmux capture-pane -pe".

Fixes #11373
Fixes 17b4b39c8b (Stop reading terminfo database, 2025-03-20).
2025-04-11 22:20:45 +02:00
Johannes Altmanninger
fee48f8508 Remove stale output buffering code
This is handled above.
2025-04-11 22:20:45 +02:00
Daniel Rainer
9618a38215 Make control flow more explicit, log errors 2025-04-11 17:52:27 +02:00
Daniel Rainer
5c0fddae70 Refactor history flushing
Use function names which explicitly state their flushing behavior.
When writing history items to a new file, flushing is only done at the end.
When appending items to an existing file, flushing is done for each item, in
order to keep the `first_unwritten_new_item_index` counter consistent with the
file system.
2025-04-11 17:52:27 +02:00
Daniel Rainer
5c8d822ee1 Flush history with sync
- Replace the write_loop call with Writer::write_all.
- Call sync_all on the file to ensure it gets written to storage.
2025-04-11 17:52:27 +02:00
Fabian Boehm
170b3593a0 CHANGELOG 2025-04-11 17:39:56 +02:00
Fabian Boehm
b815fff292 Set $__fish_data_dir to empty for embed-data builds
These builds do not use it, and setting it makes it possible to use
stale files.

So instead, we set it to empty. All uses I could find are either fine
with that (`set fish_function_path $__fish_data_dir/functions` - which
would also just be empty, which means it reads the embedded
functions),

or would break even if the variable was set but the directory was
empty (`source $__fish_data_dir/completions/git.fish`).
2025-04-11 17:29:22 +02:00
Fabian Boehm
329cd7d429 Make functions, completions and tests resilient to running on an embed-data fish
In case a completion needs a function from another script, run
`complete -C"foo "` to load it, so the full autoloading logic is used.

Otherwise these things break if the path is off. E.g. cargo's version
will fail if you override the cargo completion in
~/.config/fish/completions without also overriding the rustup
completions.

In other cases, fix for empty $__fish_data_dir, which will be coming in the next commit
2025-04-11 17:29:22 +02:00