Commit graph

16148 commits

Author SHA1 Message Date
Fabian Boehm
a750b28eb4 funced: Use a read prompt *string*
This used a prompt command, but since the prompt was interpolated and
included a `?` it would be run as a glob without qmark-noglob.

Since it's simpler to pass a prompt string, just do that.
2022-09-10 17:42:16 +02:00
Fabian Boehm
79642995f1 docs: ctrl-r is only history pager in emacs mode
We do not currently have a vi-binding for it because ctrl-r is redo
there.
2022-09-10 15:17:56 +02:00
ridiculousfish
5cf0778207 Claim the tty unconditionally in reader_data_t::readline
When fish runs with job control enabled, it transfers ownership of the
tty to a child process, and then reclaims the tty after the process
exits. If job control is disabled then fish does not transfer or reclaim
the tty.

It may happen that the child process creates a pgroup and then transfers
the tty to it. In that case fish will not attempt to reclaim the tty, as
fish did not transfer it. Then when fish reads from stdin it will
receive SIGTTIN instead of data.

Fix this by unconditionally claiming the tty in readline().

Fixes #9181
2022-09-09 13:43:29 -07:00
ridiculousfish
331bb9024b clang-format reader.cpp
We had an errant newline incompatible with our format.
2022-09-09 11:35:06 -07:00
Fabian Boehm
cab7984a7c Explicitly CHANGELOG math division by zero behavior change 2022-09-09 20:07:56 +02:00
Fabian Boehm
3981137034 CHANGELOG 2022-09-09 19:03:18 +02:00
Fabian Boehm
bc1a5ba033 Test division by zero with min
This would actually return any finite argument before!
2022-09-09 18:52:45 +02:00
Fabian Boehm
24fd26ae6e Fix error for vararg functions with zero arguments 2022-09-09 18:52:45 +02:00
Fabian Boehm
c284c4ca99 Add length also for too-many/few-args error 2022-09-09 18:52:45 +02:00
Fabian Boehm
a3ee7da812 math: Add length to missing operator error 2022-09-09 18:52:45 +02:00
Fabian Boehm
52e065e479 math: Add error length
Like we now do for syntax errors, this marks the extent of the error.

Currently for unknown functions only, would be cool for division too
2022-09-09 18:52:45 +02:00
Fabian Boehm
5edba044a3 math: Give a proper error for division by zero
This errored out *later* because the result was infinite or NaN, but
it didn't actually stop evaluation.

I'm not sure if there is a way to get floating point math to turn an
infinity back into something that doesn't depend on a literal
infinity, but division by zero conceptually isn't a thing we can
support.

There's entire branches of maths dedicated to figuring out what
dividing by "basically zero" means and we don't have to get into it.
2022-09-09 18:52:45 +02:00
Fabian Boehm
7f1e9bf57f Also convert fish_job_summary 2022-09-09 18:49:57 +02:00
Fabian Boehm
d5db260375 Use string shorten for git
This checked the locale, but did so in a way that's fundamentally
broken:

1. $LANG isn't the only variable ($LC_ALL and $LC_CTYPE)
2. Even if $LANG is set that doesn't mean it's actually working

We could add a `status is-multibyte` here to figure out if we have a
multibyte locale?

But instead, since this is dealing with adding an ellipsis, let's just
add it to `string ellipsize`.

One slight difference is that shortening the branch now counts the ellipsis width.

I.e. assuming the branch is "long-branch-name"

```fish
set -g __fish_git_prompt_shorten_branch_len 8
```

might now print "long-br…" instead of "long-bra…". This is nicer because we can now give the actual maximum width.

The alternative is to add a "--exclusive" option to "string ellipsize" that doesn't count the ellipsis width. So `string ellipsize --char "..." --max 8" long-branch-name` might result in "long-bra...", which is 11 wide.
2022-09-09 18:49:57 +02:00
Fabian Boehm
41c22d5e60 Add string shorten
This is essentially the inverse of `string pad`.
Where that adds characters to get up to the specified width,
this adds an ellipsis to a string if it goes over a specific maximum width.
The char can be given, but defaults to our ellipsis string.
("…" if the locale can handle it and "..." otherwise)

If the ellipsis string is empty, it just truncates.

For arguments given via argv, it goes line-by-line,
because otherwise length makes no sense.

If "--no-newline" is given, it adds an ellipsis instead and removes all subsequent lines.

Like pad and `length --visible`, it goes by visible width,
skipping recognized escape sequences, as those have no influence on width.

The default target width is the shortest of the given widths that is non-zero.

If the ellipsis is already wider than the target width,
we truncate instead. This is safer overall, so we don't e.g. move into a new line.
This is especially important given our default ellipsis might be width 3.
2022-09-09 18:49:57 +02:00
exploide
3e3996c9a5 completions pipenv: made pipenv completions compatible with recent versions
pipenv switched from older click-completion package to new built-in completions
from click framework in v2021.11.9.
This command achieves compatibility with both, older and more recent versions.
2022-09-09 18:47:24 +02:00
exploide
15a89718ae completions: improved resolvectl completions and complete arguments 2022-09-09 18:46:25 +02:00
NextAlone
7de0b6410d update fastboot reboot subcommand 2022-09-09 18:45:58 +02:00
Fabian Boehm
09a50a2b1e Fix typo 2022-09-08 22:50:28 +02:00
Fabian Boehm
dbeb667ff4 Document history pager 2022-09-08 22:50:00 +02:00
EJ
1d1a3d6e82
Add fortune completions (#9177)
* Add fortune completions

Add -r for required parameters

* add updates to changelog
2022-09-07 09:46:45 +02:00
杉山 恒始
01c8654459
fix completions for tcpdump (-w and -r option) (#9175)
* fix completions for tcpdump (-r option)

* fix completions for tcpdump (-w option)
2022-09-07 09:45:24 +02:00
Fabian Boehm
612e66af0f prompt_pwd: Escape $HOME
This is used with a regex, so if it contained any metacharacters
they'd be used.
2022-09-04 09:18:57 +02:00
Fabian Boehm
f9a5d4ec7f Remove useless use of awk 2022-09-02 13:28:11 +02:00
Fabian Boehm
d0fe3fcb5a Add missing "--"
The current token is often an option, and it shouldn't spew.

Also silence stderr for `cargo search` in case lookup fails.
2022-09-02 13:00:47 +02:00
Mahmoud Al-Qudsi
9466ff2a22 Provide dynamic completions for cargo {add,install}
`cargo search` can be used to quickly get crates matching a search string, so we
can pass the current token for first-arg completions to `cargo add` and `cargo
install` to `cargo search` to look up matches.

`cargo search` doesn't restrict itself to (nor prioritize for) prefix matches,
while fish will only display prefix matches (for dynamically generated
completions) so it's perfectly possible for `cargo search foo` to return 20
results none of which will successfully result in a completion, but for a
further-narrowed completion of `cargo install foob^I" to then result in
completions because `cargo search` ended up returning a prefix match for `foob`
while it didn't for `foo`.

The only other oob cargo subcommand that takes a crate name (that isn't the name
of a crate specified in `Cargo.toml`) is `cargo search` but there's no point in
providing completions to that... I think (it's possible to search for crate
"foo" in order to get its latest version number rather than its name, but I'm
not sure that's worth supporting).
2022-09-01 13:56:59 -05:00
Mahmoud Al-Qudsi
db92109db5 Support top-level completion of user-installed cargo subcommands
This expands completions of `cargo^I` to list any commands named `cargo-xxx` as
cargo subcommands invokable as `cargo xxx` in addition to the default oob
subcommands cargo ships with.

(This is very similar to how git allows users to shim their own subcommands.)

NOTE: This would stay even after cargo someday moves to clap and generates or
even ships/installs an official machine-generated `cargo.fish` completions
script.
2022-09-01 12:22:31 -05:00
Aaron Gyes
147105744e I ommitted a newline here
in 98692e0309
2022-08-31 22:15:56 -07:00
Weihang Lo
b796716901 Remove non-existing cargo subcommand
The old way of generating cargo completions no longer work, so we need
to manually maintain the completions until clap completions support[1].

[1]: https://github.com/clap-rs/clap/issues/3166
2022-08-31 17:35:52 -05:00
Aaron Gyes
08129537e8 timer.cpp: iwyu; update includes
after aaf50099f2
2022-08-30 23:56:33 -07:00
Aaron Gyes
c35b935e61 fallback.cpp: iwyu; update includes 2022-08-30 23:55:26 -07:00
Johannes Altmanninger
3b30d92b62 Commit transient edit when closing pager
When selecting items in the pager, only the latest of those items is kept
in the edit history, as so-called transient edit.  Each new transient edit
evicts any old transient edit (via undo).

If the pager is closed by a command that performs another transient edit
(like history-token-search-backward) we thus inadvertently undo (= remove)
the token inserted by the pager.  Fix this by closing a transient edit
session when closing the pager.  Token search will start its own session.

Fixes #9160
2022-08-31 07:49:49 +02:00
Johannes Altmanninger
a6ff72bd64 faq.rst: fix typo 2022-08-31 07:49:49 +02:00
Fabian Boehm
26285280a9 Remove some dead code 2022-08-27 20:33:39 +02:00
Fabian Boehm
b08490f051 Replace our use of strncpy
strncpy will fill the entire buffer with NUL.

In this case we have a 128 byte buffer and write "empty" - 5 bytes -
into it.

So now instead of writing 6 bytes it'll write 128 bytes. Especially
wasteful because we already did memset before
2022-08-27 17:47:18 +02:00
Fabian Boehm
07b2f1054b disco prompt: Pad hash
It's possible cksum returns less than 3 full bytes, so let's just turn the
ones we don't get into 0

Fixes #9164
2022-08-27 16:38:36 +02:00
Fabian Boehm
227e1f6300 color: Use convert_digit
I can't believe how many "read this one hex digit" functions we have.
2022-08-27 11:41:29 +02:00
Fabian Boehm
5e0f5eff37 Remove wcsdup fallback
2a0e0d6721 removed the last use of it,
and in most cases we'd probably prefer to use a wcstring instead
2022-08-27 11:36:15 +02:00
Fabian Boehm
4dfcd4cb4e reader: Check bounds for color
This fixes a crash when you open the history pager and then do
history-token-search-backward (e.g. alt+. or alt-up).

It would sometimes crash because the `colors.at(i)` was an
out-of-bounds access.

Note: This might still leave the highlighting offset in some
cases (not quite sure why), but at least it doesn't *crash*, and the
search generally *works*.
2022-08-26 15:02:05 +02:00
Fabian Boehm
ec8a7d09c6 completions/ant: Replace bogus realpath usage
This used `realpath -eq`, which for GNU realpath:

1. Suppresses "most error messages" (-q)
2. Requires that all parts exist (rather than allowing the last not
to)

Since we don't actually need a real path here, just filter.

Fixes #9099
2022-08-25 19:01:41 +02:00
Fabian Boehm
a42a651d0a Use color for $fish_color_valid_path if it exists
This otherwise threw away the color. Since that's just information
that is thrown away, let's just use it.

Fixes #9159.
2022-08-25 17:42:42 +02:00
bagohart
106e030096
added completions for sad (#9145)
* added completions for sad and added note in changelog

* ran fish_indent on completion file

* split -h and --help into two distinct completion options
2022-08-25 13:20:15 +02:00
Fabian Boehm
c753f22003 docs: Format path synopsis
This was written while we changed how our synopses are formatted, so
we missed adding a "synopsis" marker to it.

The tokenizer here is a bit cheesy, so we can't mark continuation
lines with a "\", and we also can't mark the general options with a
":=". Tbh that's not a big deal.

Fixes #9154
2022-08-25 13:06:57 +02:00
Fabian Boehm
6581362e1e Remove debug-stack-frames from fish completions
This was broken in the move to FLOG.

Fixes #9155
2022-08-24 20:03:46 +02:00
Fabian Boehm
7e75118956 Document math's lack of bitnot
Fixes #9148
2022-08-23 19:55:55 +02:00
Fabian Boehm
9e9c73e46a tests/signals.py: Kill leftover sleeps from python
This starts two sleep processes and expects them to be killed on
SIGHUP.

Unfortunately, if this ever fails the second run will also fail
because it'll see the old sleep still lying around (because it'll run
for 130 seconds).

So, what we do is:

1. Keep the pids for these specific sleeps
2. Check if any of them are still running (and only fail for them)
3. Kill them from python

Fixes #9152
2022-08-23 18:47:52 +02:00
Aaron Gyes
50d37527a9 Revert "I need to take a break. Fixup."
This reverts commit 3e556b984c.

Revert "Further fix the issue and add the assert that'd have prevented it."

This reverts commit 056502001e.

Revert "Fix actual issue with allow_use_posix_spawn."

This reverts commit 85b9f3c71f.

Revert "Stop using posix_spawn when it is not allowed"

This reverts commit 9c896e1990.

Revert "don't even set up a fish_use_posix_spawn handler if unsupported"

This reverts commit 8b14ac4a9c.
2022-08-22 14:11:52 -07:00
Aaron Gyes
3e556b984c I need to take a break. Fixup. 2022-08-22 13:55:44 -07:00
Aaron Gyes
056502001e Further fix the issue and add the assert that'd have prevented it.
Surprise: because FISH_USE_POSIX_SPAWN was from postfork.h, we
also were disabling things when we don't want to as well.
2022-08-22 13:53:41 -07:00
Aaron Gyes
85b9f3c71f Fix actual issue with allow_use_posix_spawn.
We were testing the function pointer, not evaluating the function.

This should be the proper fix. Thanks @ridiculousfish
2022-08-22 13:30:51 -07:00