Commit Graph

14008 Commits

Author SHA1 Message Date
David Adam
b05275cedc docs: remove undo-group functions from documentation
As discussed in
85ffa77b4e
these functions are not intended for long term use.

Also fix a typo introduced in 85ffa77.
2021-04-06 21:18:21 +08:00
exploide
89eeafe393 added completions for firewall-cmd (firewalld)
based on --help and man page of firewall-cmd 0.9.x
2021-04-05 18:59:58 -07:00
ridiculousfish
fa890dc233 Prevent hanging when restoring the foreground process group at exit
When fish starts, it notices which pgroup owns the tty, and then it
restores that pgroup's tty ownership when it exits. However if fish does
not own the tty, then (on Mac at least) the tcsetpgrp call triggers a
SIGSTOP and fish will hang while trying to exit.

The first change is to ignore SIGTTOU instead of defaulting it. This
prevents the hang; however it risks re-introducing #7060.

The second change somewhat mitigates the risk of the first: only do the
restore if the initial pgroup is different than fish's pgroup. This
prevents some useless calls which might potentially steal the tty from
another process (e.g. in #7060).
2021-04-05 18:05:06 -07:00
ridiculousfish
ed51e2baac Prevent hanging when restoring the foreground process group at exit
When fish starts, it notices which pgroup owns the tty, and then it
restores that pgroup's tty ownership when it exits. However if fish does
not own the tty, then (on Mac at least) the tcsetpgrp call triggers a
SIGSTOP and fish will hang while trying to exit.

The first change is to ignore SIGTTOU instead of defaulting it. This
prevents the hang; however it risks re-introducing #7060.

The second change somewhat mitigates the risk of the first: only do the
restore if the initial pgroup is different than fish's pgroup. This
prevents some useless calls which might potentially steal the tty from
another process (e.g. in #7060).
2021-04-05 17:44:14 -07:00
ridiculousfish
a69e94d954 add_disowned_job to accept its parameter by const pointer
It never modified the job.
2021-04-03 21:05:32 -07:00
ridiculousfish
797fbbb5f5 Remove the SIGIO signal handler and universal notifier
If fish launches a program and that program marks stdin as O_ASYNC, then
fish will start receiving SIGIO events on Mac. This occurs even though
the file descriptor itself does not have the O_ASYNC flag set.

SIGIO is reported as interrupting select which then breaks multiple-key
bindings, especially in vi-mode.

As the SIGIO based universal notifier is disabled, remove it and the
SIGIO handler itself. This allows fish to ignore properly ignore SIGIO.

Fixes #7853
2021-04-03 18:17:34 -07:00
ridiculousfish
73ec89917a Remove the SIGIO signal handler and universal notifier
If fish launches a program and that program marks stdin as O_ASYNC, then
fish will start receiving SIGIO events on Mac. This occurs even though
the file descriptor itself does not have the O_ASYNC flag set.

SIGIO is reported as interrupting select which then breaks multiple-key
bindings, especially in vi-mode.

As the SIGIO based universal notifier is disabled, remove it and the
SIGIO handler itself. This allows fish to ignore properly ignore SIGIO.

Fixes #7853
2021-04-03 18:11:29 -07:00
ridiculousfish
36ad116b34 Properly report errors when builtin output fails
This correctly sets $status when a builtin succeeds but its output fails;
for example if the output is redirected to a file and that write fails.

Fixes #7857
2021-04-03 16:11:25 -07:00
Phil Corbett
13439b399e Shortens RPM completions 2021-04-02 12:37:59 -07:00
Fabian Homborg
19004642ba __fish_apropos: Define again on non-macOS
This had a weirdly broken if condition.
2021-04-02 16:58:34 +02:00
Aaron Gyes
b9b2010342 rebuild whatis database weekly, not daily
I still don't think we even address rebuilding
manpage completions yet. Maybe they could share a
solution.
2021-04-02 02:12:00 -07:00
Aaron Gyes
0e03e49eb9 __fish_apropos: prepend $argv with ^
Because macOS' `apropos` is just using grep, and we only need
a prefix match for __fish_describe_command, we can shave off
some ok total execution time here.
2021-04-02 01:58:38 -07:00
Aaron Gyes
85e3381480 __fish_apropos: refactor, limit to 10.15+, change default cache dir.
No longer uses the __fish_apropos hack on every version of macOS.
Juat Catalina+.

The whatis database generated and replaced daily is 2 megabytes on
my computer, and in ~/.cache on a home dir might wind up on a net
mount or something annoying. or, definitely it's backed up by default.

It's wiser to throw that junk in with other cache files on the system
aka DARWIN_USER_CACHE_DIR, and only use the XDG directory if
someone specifically configured that.

Mainly, this just means at least it won't automatically get backed
up by Time Machine and stuff every day, which is no big deal but
y'know...

Rearranged stuff a little to not shell out every time.
2021-04-02 01:58:38 -07:00
Johannes Altmanninger
ed5e5a9d49 Enhance greppability of the "return symbol" for abandoned newlines
Was looking for this for #7893
2021-04-02 08:09:56 +02:00
Fabian Homborg
e19a2f9f85 Github: Force using vendored pcre2
It seems an update to the ubuntu image github uses included pcre2, but
only the 64-bit version.

So since we now force a 32-bit fish but don't force the vendored pcre,
it complains.

Simply force the vendored pcre as well as I don't believe it's worth
it to change the pcre2 detection in this case.
2021-04-01 22:58:25 +02:00
David Adam
16bc170126 CHANGELOG: work on 3.3.0 2021-04-01 23:42:56 +08:00
Johannes Altmanninger
a4a42fa2c3 completions/aura: remove outdated flag
Commit a0b46e620 ("Update Aura completions") removed "abs", but forgot
it here.

Fixes #7865

(cherry picked from commit dc417f58ae)
2021-04-01 22:54:04 +08:00
Jannik Vieten
0efc55cbe9 Fix completion errors for tshark when running as root (#7858)
(cherry picked from commit 0f3274d5eb)
2021-04-01 22:54:04 +08:00
Fabian Homborg
92c28291df Only donate term if we're interactive *and* have the terminal
As it turns out otherwise fish would hang when sddm starts it as the login shell.

Belongs to #7842.

(cherry picked from commit 7f7cfcf339)
2021-04-01 22:54:04 +08:00
ridiculousfish
e31096d7ed Skip long arguments in syntax highlighting path detection
When fish performs syntax highlighting, it attempts to determine which
arguments are valid paths and underline them. Skip paths whose length
exceeds PATH_MAX. This is an optimization: such strings are almost
certainly not valid paths and checking them may be expensive.

Relevant is #7837

(cherry picked from commit 8d54d2b60e)
2021-04-01 22:54:04 +08:00
ridiculousfish
8b825bf760 Reimplement wbasename and wdirname
Previously wbasename and wdirname wrapped the system-provided basename
and dirname. But these have thread-safety issues and some surprising
error conditions on Mac. Just reimplement these per the OpenGroup spec.

In particular these no longer trigger a null-dereference if the input
exceeds PATH_MAX.

Add some tests too.

This fixes #7837

(cherry picked from commit cf35431af9)
2021-04-01 22:54:04 +08:00
ridiculousfish
951fc6b954 Add some tests for dirname and basename
This is in preparation for replacing our wrappers around the C versions,
with custom versions instead.

(cherry picked from commit 6e1b324343)
2021-04-01 22:54:04 +08:00
ridiculousfish
3a8e0e4c37 Don't block certain error signals on background threads
Previously fish attempted to block all signals on background threads, so
that they would be delivered to the main thread. But on Mac, SIGSEGV
and probably some others just get silently dropped, leading to potential
infinite loops instead of crashing. So stop blocking these signals.

With this change the null-deref in #7837 will properly crash instead of
spinning.

(cherry picked from commit a7c37e4af4)
2021-04-01 22:54:04 +08:00
ridiculousfish
0b144baa79 Switch fish.pc dependency from FBVF file to CHECK-FBVF target
Previously, both fish.pc and libfish had generating the
FISH-BUILD-VERSION-FILE attached as a command. In principle they could
both try to run the command simultaneously and now CMake complains about
this with the Xcode generator.

Switch to having fish.pc depend on the CHECK-FISH-BUILD-VERSION-FILE as a
target instead of a command. This allows it to participate in dependency
resolution and CMake will succeed again.

Fixes #7838

(cherry picked from commit 1b950f5f3b)
2021-04-01 22:54:04 +08:00
Fabian Homborg
9221a3deca Only set modes after config.fish if we're *interactive*
013a563ed0 made it so we only try to
adjust terminal modes if we are in the terminal pgroup, but that's not
enough.

Fish starts background jobs in events inside its own pgroup, so

    function on-foo --on-event foo
        fish -c 'sleep 3' &
    end

would have the backgrounded fish try to fiddle with the terminal and
succeed.

Instead, only fiddle with the terminal if we're interactive (this
should probably be extended to other bits, but this is the particular
problematic part)

Fixes #7842.

(cherry picked from commit e4fd664bbb)
2021-04-01 22:54:04 +08:00
Fabian Homborg
b2baf110c5 Disable pacman command-not-found handler
Apparently it's too slow on some systems

Fixes #7841.

(cherry picked from commit 95dc821a44)
2021-04-01 22:54:04 +08:00
Fabian Homborg
e56d8a8e5e Changelog new fish_mode_prompt 2021-03-31 18:06:17 +02:00
Fabian Homborg
419675b9e5 mode_prompt: Use foreground instead of background colors
The default vi mode prompt is kind of ugly, mostly because we include
this `[I]` with a super bright green background and white text,
which is particularly grating because most prompts don't actually have
a background.

So we get a ton of people asking "How do I remove this [I]" when they
could really benefit from having the mode shown.

There's a few ways to make this look nicer, the simplest is to just
keep the same colors but use them as foreground instead of background
colors, which looks much more understated.

The mode prompt is important, but not more than the actual contents of
the commandline, so it shouldn't have ALARMING colors.
2021-03-31 18:04:53 +02:00
Fabian Homborg
f1d3e7a0db docs: Reorder ToC
Roughly the order I expect these to be used in.
2021-03-31 17:21:46 +02:00
Fabian Homborg
b5a5d98f80 docs: Add missing "`"
Fixes a sphinx warning.
2021-03-31 17:21:46 +02:00
Fabian Homborg
dbd608cb6a tinyexpr: Use cmath with std::
The oldschool math.h imports the math functions into the global
namespace, cmath imports them into std::.

Unfortunately, we already use cmath elsewhere, and including math.h
doesn't reimport them in some systems, so now they can't find them
with std::.

Fixes #7882.
2021-03-31 17:21:46 +02:00
David Adam
0c03a0267f Revert "tinyexpr: use std:: namespace for older libstdc++"
This reverts commit f46444f106.

This commit does not build on macOS or RHEL 7.
2021-03-31 22:53:18 +08:00
David Adam
f46444f106 tinyexpr: use std:: namespace for older libstdc++
Fixes the build on Ubuntu Xenial 16.04 and CentOS 7.
2021-03-31 11:21:42 +08:00
David Adam
85ffa77b4e docs: note undocumented input functions
Noted in #7828.
2021-03-31 10:41:21 +08:00
Michael Jarvis
f9e95e5f5b Fix Sphinx warning
For some reason, the space in seems to cause a problem.

```
../CHANGELOG.rst:30: WARNING: Inline literal start-string without end-string.
```
2021-03-30 18:05:37 +02:00
Fabian Homborg
f75cf5c16b git prompt: Use status --porcelain for informative status
This allows us to stop descending into untracked directories, which
can be faster.

It's still not *good* - git can still be quite slow here, but if
there's an untracked directory you probably don't care about the
number of files in that.

Fixes #7871.
2021-03-30 17:51:34 +02:00
Fabian Homborg
93ce805f32 help: Update completions
This is all of the sections in interactive, language and for_bash_users.

The faq names are so long that we're not adding them, also not all of
these have descriptions yet.
2021-03-30 17:40:38 +02:00
Fabian Homborg
ed9268f99c
math: Make function parentheses optional (#7877)
* math: Make function parentheses optional

It's a bit annoying to use parentheses here because that requires
quoting or escaping.

This allows the parens to be omitted, so

math sin pi

is the same as

math 'sin(pi)'

Function calls have the lowest precedence, so

math sin 2 + 6

is the same as

math 'sin(2 + 6)'

* Add more tests

* Add a note to the docs

* even moar docs

Moar docca

* moar tests

Call me Nikola Testla
2021-03-30 17:21:28 +02:00
Fabian Homborg
d5cba5fe12 Teach help to pick the correct page
Given that we no longer have that massive "index" page with
everything, it's become harder to open the correct section
immediately.

So this hardcodes the section titles for each page in help itself.

This was half-automated with

grep -o 'a class="headerlink" href="#[^"]*"' /usr/share/doc/fish/faq.html | sort -u | string replace -r '.*#' '' | string trim -c '"'

The completions still need to be adjusted.
2021-03-30 17:14:14 +02:00
Fabian Homborg
18e332772d functions: Add "--no-details" flag and use it in funced
This inhibits the function path comment which is annoying in `funced`.

Fixes #7879.
2021-03-30 16:54:26 +02:00
Karolina Gontarek
da2f7999ad
Fix backward-kill-path-component erasing extra tokens (#7872)
Fixes #6258
2021-03-29 22:58:50 +02:00
Fabian Homborg
fd4803ac6a Update BEL comment
We no longer send it.
2021-03-29 18:03:36 +02:00
Fabian Homborg
70813eb878 Update CHANGELOG 2021-03-29 18:00:38 +02:00
Fabian Homborg
312cfacf71 Don't ring the bell in reader_flash
The bell is a mechanism for important notifications. Not having things
to do in response to a keypress isn't important enough, especially
because we're already flashing and the bell might actually be a bell.

Fixes #7875.
2021-03-29 17:49:47 +02:00
Fabian Homborg
e1d19cf571 Don't touch $SHLVL if not interactive
It's not super clear what $SHLVL is useful for, but the current
definition is essentially
"number of shells in the parent processes + 1"

which isn't *super useful*?

Bash's behavior here is a bit weird in that it increments $SHLVL
basically always, but since it auto-execs the last process it will
decrement it again, so in practice it's often not incremented.

E.g.

```
> echo $SHLVL
1
> bash -c 'echo $SHLVL; bash'
2
>> echo $SHLVL
2
```

Both bashes here end up having the same $SHLVL because this is
equivalent to `echo $SHLVL; exec bash`. Running `echo $SHLVL` and then
`bash -c 'echo $SHLVL'` in an interactive bash will have a different
result (1 and 2) because that doesn't *exec* the inner bash.

That's not something we want to get into, so what we do is increment
$SHLVL in every interactive fish. Non-interactive fish will simply
import the existing value.

That means if you had e.g. a bash that runs a fish script that ends up
opening a new fish session, you would have a $SHLVL of *2* - one for the
bash, and one for the inner fish.

We key this off is_interactive_session() (which can also be enabled
via `fish -i`) because it's easy and because `fish -i` is asking for
fish to be, in some form, "interactive".

That means most of the time $SHLVL will be "how many shells am I deep,
how often do I have to `exit`", except for when you specifically asked
for a fish to be "interactive". If that's a problem, we can rethink it.

Fixes #7864.
2021-03-29 17:44:13 +02:00
Hirokazu Hata
f1c93a99f9 changelog: fix missiong inline literal end-string
When building the document with Sphinx, the following warning is displayed, so add end-string.
"../CHANGELOG.rst:29: WARNING: Inline literal start-string without end-string."
2021-03-29 17:05:23 +02:00
ridiculousfish
0f0995cad0 Remove unused COMMAND_NOT_BUILTIN enum
This was an enum whose values were never used; we can just remove it.
2021-03-28 22:19:36 -07:00
ridiculousfish
0aec597a36 Switch a cast from C style to C++ style 2021-03-28 20:04:34 -07:00
ridiculousfish
48868e5667 Switch builtin execution to the performer model
In preparation for concurrent execution, introduce a
`get_performer_for_builtin` function. This function itself returns a
function, which when called will run the builtin. The idea is that the
function may be called on a background thread (but not in this commit).
2021-03-28 15:31:25 -07:00
ridiculousfish
fb92ad946b Rework null terminated arrays
Several functions including wgetopt and execve operate on null-terminated
arrays of nul-terminated pointers: a list of pointers to C strings where
the last pointer is null. Prior to this change, each process_t stored its
argv in such an array. This had two problems:

1. It was awkward to work with this type, instead of using std::vector,
etc.
2. The process's arguments would be rearranged by builtins which is
surprising

Our null terminated arrays were built around a fancy type that would copy
input strings and also generate an array of pointers to them, in one big
allocation.

Switch to a new model where we construct an array of pointers over
existing strings. So you can supply a `vector<string>` and now
`null_terminated_array_t` will just make a list of pointers to them. Now
processes can just store their argv in a familiar wcstring_list_t.
2021-03-28 15:31:25 -07:00