Commit Graph

18845 Commits

Author SHA1 Message Date
Fabian Boehm
f4a3dcca3a docs: Clarify command substitution section
Put `$()` version front-and-center and make the quoting more
prominent.

In turn mention `()` as a version that can't be quoted.
2024-04-01 15:40:25 +02:00
David Adam
3a98db46bc
build.rs: pick up version file for tarballs from source, not build, directory (#10400) 2024-03-31 00:43:55 -05:00
Felix Luciano Salomon
1f68d66692
Added pbpaste command completions (#10389)
* Added pbpaste command completions
2024-03-30 22:35:53 -05:00
Mahmoud Al-Qudsi
41eaf2f8dc
Merge pull request #10398 from mqudsi/forward-char-passive
Add `forward-char-passive` and `backward-char-passive`
2024-03-30 22:29:46 -05:00
David Adam
792eff42b7 discard serial_test features
The default features are async and log, which are not utilised, and add
a significant number of dependencies to the tree.
2024-03-31 00:47:38 +08:00
Johannes Altmanninger
a29cc8f169 Fix regression when selection start is deleted
Ranges with start > end are invalid; we crash with "slice index starts at
10 but ends at 0".
2024-03-30 09:56:48 +01:00
Mahmoud Al-Qudsi
8eb7a08035 Document backward-char-passive 2024-03-29 14:23:53 -05:00
Mahmoud Al-Qudsi
1adbec2d37 Add backward-char-passive 2024-03-29 14:23:51 -05:00
Mahmoud Al-Qudsi
3980e46d3a Add test for forward-char-passive 2024-03-28 00:46:41 -05:00
Mahmoud Al-Qudsi
674c481d87 Add documentation for forward-char-passive 2024-03-28 00:18:24 -05:00
Mahmoud Al-Qudsi
df09ab598f Add forward-char-passive binding
This binding is akin to ForwardSingleChar but it is "passive" in that is not
intended to affect the meta state of the shell: autocompletions are not accepted
if the cursor is at the end of input and it does not have any effect in the
completions pager.
2024-03-28 00:13:34 -05:00
Fabian Boehm
b535213ac0 CHANGELOG abbr decorators 2024-03-27 22:13:27 +01:00
Fabian Boehm
217b009e18
abbr: expand command abbrs after decorators (#10396)
Currently, we expand command-abbrs (those with `--position command`) after `if`, but not after `command` or `builtin` or `time`:

```fish
abbr --add gc "git checkout"
```

will expand as `if gc` but not as `command gc`.

This was explicitly tested, but I have no idea why it shouldn't be?
2024-03-27 17:17:55 +01:00
Mahmoud Al-Qudsi
326d986186 Fix broken read_ni() not making fd non-blocking on Linux
The incorrect order of operations was being used since && binds tighter than ||
in rust (as with most sane languages).

Under Linux, EAGAIN == EWOULDBLOCK so this would always succeed in the case of a
non-blocking fd without making the call to make_fd_nonblocking().

Comparing to the 3.7.0 C++ code, it looks like this was an oversight introduced
in the migration to rust.
2024-03-26 01:06:42 -05:00
Johannes Altmanninger
62a49acda3 completions/iwctl: fix spurious error on "iwctl device foo" 2024-03-25 20:56:08 +01:00
Johannes Altmanninger
6efe0907e9 Fix --debug-output regression
We accidentally close FLOG output file.  Let's leak it for now; in future
we should close it.
2024-03-25 20:56:08 +01:00
Johannes Altmanninger
f5d6ea6cf6 Basic completions for gdbserver 2024-03-25 05:42:16 +01:00
Johannes Altmanninger
5b324f8ecb Fix regression in parse_util_process_extent
Found on a two-line commandline

    for file in (path base<TAB>
    echo
2024-03-24 16:34:36 +01:00
Johannes Altmanninger
1216801474 Use RAII for restoring term modes
In particular, this allows restoring the terminal on crashes, which is
feasible now that we have the panic handler.  Since std::process::exit() skips
destructors, we need to reshuffle some code.  The "exit_without_destructors"
semantics (which std::process::exit() als has) was mostly necessary for C++
since Rust leaks global variables by default.
2024-03-24 16:34:36 +01:00
Johannes Altmanninger
3cfa09d1bd Make test_init() return a scope guard
To be used in the next commit.
2024-03-24 16:33:35 +01:00
Johannes Altmanninger
ecdc9ce1dd Install a panic handler to avoid dropping crash stacktraces
When fish crashes due to a panic, the terminal window is closed.  Some
terminals keep the window around when the crash is due to a fatal signal,
but today we don't exit via fatal signal on panic.

There is the option to set «panic = "abort"» in Cargo.toml, which
would give us coredumps but also worse stacktraces on stderr.
More importantly it means that we don't unwind, so destructors are skipped
I don't think we want that because we should use destructors to
restore the terminal state.

On crash in interactive fish, read one more line before exiting, so the
stack trace is always visible.

In future, we should move this "read one line before exiting" logic to where
we call "panic!", so I can attach a debugger and see the stacktrace.
2024-03-24 13:36:59 +01:00
Johannes Altmanninger
ccaf06e9d6 Fix incremental rebuild on added/deleted source file
Looks like "add_custom_command(OUTPUT ...)"  assumes the dependencies are
correct which is not always true. We can use "add_custom_target" to always
re-run Cargo.
2024-03-24 12:18:20 +01:00
Johannes Altmanninger
5c5ab4f179 Move termsize test into separate file 2024-03-24 12:18:20 +01:00
Johannes Altmanninger
99ffa4567a Remove unused import 2024-03-24 12:18:20 +01:00
Fabian Boehm
ec7c0e19d0 help: Always print what is used
Makes it easier to debug
2024-03-24 08:51:52 +01:00
Fabian Boehm
bdfa7341e7 help: Only use open on macOS
Unfortunately on Debian "open" is a symlink to "openvt", and there's
no way from outside to tell.

This prevents fish from failing because no browser could be found.
2024-03-24 08:48:58 +01:00
Johannes Altmanninger
c209e6b5fb Fix clippy lint 2024-03-23 14:26:08 +01:00
Johannes Altmanninger
58e477fab3 Changelog Vi mode changes
Closes #10338
2024-03-23 14:26:08 +01:00
Johannes Altmanninger
39ea1d710d Vi mode: add "+yy for fish_clipboard_copy and friends
Obviously not fully correct, and the implementation is not greate but it's
a start.
2024-03-23 14:24:51 +01:00
Johannes Altmanninger
25db4e803c Vi mode: don't cross newline on escape 2024-03-23 14:12:21 +01:00
Johannes Altmanninger
54b8817937 Vi mode: add + as clipboard alias, like * 2024-03-23 14:12:21 +01:00
Johannes Altmanninger
d51f669647 Vi mode: avoid placing cursor beyond last character
Today fish_cursor_selection_mode controls whether selection mode includes
the cursor. Since it's by default only used for Vi mode, perhaps use it to
also decide whether it should be allowed to select one-past the last character.

Not allowing to select to select one-past the last character is much nicer
in Vi mode.  Unfortunately Vi mode sometimes needs to temporarily select
past end (using forward-single-char and such), so reset fish_cursor_selection_mode
for the duration of the binding.

Also fix other things like cursor placement after yank/yank-pop.

Closes #10286
Closes #3299
2024-03-23 14:12:21 +01:00
Johannes Altmanninger
bffc9515a8 Fix bracketed paste regression from input event queue changes
We have

    bind --preset -M $mode --sets-mode paste \e\[200~ __fish_start_bracketed_paste

Commit c3cd68dda (Process shell commands from bindings like regular char
events, 2024-03-02) made it so __fish_start_bracketed_paste is no longer
executed before the bind mode is  updated.
This is a long-awaited fix but it broke __fish_start_bracketed_paste's
assumption that $fish_bind_mode is the mode before we entered paste mode.
This means we never exit paste mode.

Work around that. I forgot about this issue because I already replaced our
bracketed paste handling on my fork.
2024-03-23 14:08:55 +01:00
Fabian Boehm
b3ce8eee60 Remove some more C++-isms 2024-03-23 11:54:23 +01:00
Fabian Boehm
d99a5bae88 Remove trace of corrosion 2024-03-23 11:52:49 +01:00
Fabian Boehm
6eaaa3adc3 Revert "Try to fix OBS tumbleweed builds"
This was a misunderstanding, the OBS tumbleweed builds build from a tarball that's pushed manually.

We no longer use corrosion so this dependency is unused.

This reverts commit bdde2b2b35.

Fixes #10391
2024-03-23 11:51:19 +01:00
Pi-Cla
0cbac81130 Bump serial_test dependency to 1.0.0
The current version of serial_test we use (0.4.0)
depends on parking_lot 0.10.2 which in turn
depends on lock_api 0.3.4.
This version of lock_api is vulnerable to [RUSTSEC-2020-0070](https://rustsec.org/advisories/RUSTSEC-2020-0070)
This was patched in lock_api 0.4.2 but we need to update serial_test
to get the update.
2024-03-23 11:01:35 +01:00
Johannes Altmanninger
8baf7de4c0 Vi mode: remove stale comment 2024-03-23 10:38:28 +01:00
Johannes Altmanninger
0f758f12b7 environment.rs: minor cleanup 2024-03-23 10:38:28 +01:00
Johannes Altmanninger
789a280ee8 Fix {Alt,Shift}-Return bindings not expanding abbreviations
Today,

    bind foo "commandline -f expand-abbr; commandline -i \n"

does not work because this
1. enqueues an expand-abbr readline event
2. "commandline -i" inserts \n
3. processes the expand-abbr readline event

Since there is no abbreviation on the new line, this doesn't do anything.

PR https://github.com/fish-shell/fish-shell/pull/9398 would fix this
particular instance however it does not fix the issue that "commandline -i"
is run before the expand-abbr is processed by the reader. This is harmless
here but there would be a problem if "commandline" tried to read commandline
state that was created by a preceding command.

It's not super clear to me whether the above binding should work as one
would naively expect. That would imply that "commandline" would need to
drain all input events (at least all synthetic ones) from the input queue,
to ensure it sees the current state.

Fortunately the parent commit makes it so if we separate them

    bind foo "commandline -f expand-abbr" "commandline -i \n"

both will be separate events and the commandline state will be synced after
each of them. This fixes abbreviation expansion here.

Also, we can now mix readline cmds and shell commands, which makes it shorter.
2024-03-23 10:06:11 +01:00
Johannes Altmanninger
c3cd68dda5 Process shell commands from bindings like regular char events
A long standing issue is that bindings cannot mix special input functions
and shell commands. For example,

    bind x end-of-line "commandline -i x"

silently does nothing. Instead we have to do lift everything to shell commands

    bind x "commandline -f end-of-line; commandline -i x"

for no good reason.

Additionally, there is a weird ordering difference between special input
functions and shell commands. Special input functions are pushed into the
the queue whereas shell commands are executed immediately.

This weird ordering means that the above "bind x" still doesn't work as
expected, because "commandline -i" is processed before "end-of-line".

Finally, this is all implemented via weird hack to allow recursive use of
a mutable reference to the reader state.

Fix all of this by processing shell commands the same as both special input
functions and regular chars. Hopefully this doesn't break anything.

Fixes #8186
Fixes #10360
Closes #9398
2024-03-23 10:06:11 +01:00
Johannes Altmanninger
c1f601f31e Don't bind Alt-Return in Vi normal mode
It seems wrong because it's for text insertion; if someone actually wants
to use it we can add it back.
2024-03-23 09:54:18 +01:00
Johannes Altmanninger
865118e3b4 On Shift+Return, insert a newline instead of executing the commandline
Most chat programs I found use Shift+Return to insert a newline while plain
Return sends the message. One user reported having only tried Shift+Return
and not knowing about Alt+Return.

No release notes yet because this only works on a very small number of
terminals. Once we enable CSI u, this should work on most modern terminals.
2024-03-23 09:54:18 +01:00
Johannes Altmanninger
232483d89a History pager to only operate on the line at cursor
Multiline search strings are weirdly broken (inserting control characters
in the command line) and probably not very useful anyway.
On the other hand I often want to compose a multi-line command
from single-line commands I ran previously.

Let's support this case by limiting the initial search string to the current
line; and replace only that line.

Alternatively this could operate on jobs (that is, replace a surrounding
"foo | bar") instead of using line boundaries.
2024-03-23 09:54:18 +01:00
Johannes Altmanninger
299fcde808 Better link for POSIX test 2024-03-23 09:51:09 +01:00
Mahmoud Al-Qudsi
0ca199ef98 Change wopen_cloexec() to return File 2024-03-23 01:34:23 -05:00
Mahmoud Al-Qudsi
8d9d4ce1f9 Add and use separate open_dir() method
This is resistant to misuse by including O_DIRECTORY in the open flags and it is
a separate function from {w,}open_cloexec() in preparation for making that one
return a `File` instead of an `OwnedFd`.
2024-03-23 01:15:43 -05:00
Mahmoud Al-Qudsi
99c9d6eef6 IoFile: Wrap File instead of OwnedFd 2024-03-23 00:44:27 -05:00
Mahmoud Al-Qudsi
6f9f9ee400 Use bitflags contains() instead of intersects()
`intersects()` is "any of" while `contains()` is "all of" and while it makes no
difference when testing a single bit, I believe `contains()` is less brittle
for future maintenance and updates as its meaning is clearer.

</pedantic>
2024-03-23 00:24:31 -05:00
Mahmoud Al-Qudsi
6ed4d09c93 Switch more to File/BorrowedFd from OwnedFd/RawFd
More work in prep for having wopen_cloexec() return `File` directly.

This eliminates checking for an invalid fd and makes both ownership and
mutability clear (some more operations that involve changes to the underlying
state of the fd now require `&mut File` instead of just a `RawFd`).

Code that clearly does not use non-blocking IO is ported to use
`Write::write_all()` directly instead of our rusty port of the `write_loop()`
function (which handles EAGAIN/EWOULDBLOCK in addition to EINTR, while
`write_all()` only handles the latter).
2024-03-23 00:01:57 -05:00