Commit Graph

16105 Commits

Author SHA1 Message Date
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
ridiculousfish
9c896e1990 Stop using posix_spawn when it is not allowed
Commit 8b14ac4a9c started using
posix_spawn even if allow_use_posix_spawn() returns false. Stop doing
that.

This may be reproduced with:

    ./docker/docker_run_tests.sh ./docker/centos7.Dockerfile

as centos7 has a too-old glibc.
2022-08-21 16:25:26 -07:00
ridiculousfish
60621e086c Fix the centos7 Dockerfile
The git224-core package has disappeared. Use git236 instead.
2022-08-21 15:46:09 -07:00
ridiculousfish
aaf50099f2 Stop using a static vector for timers
This is thread unsafe. Just use a captured local variable instead.
2022-08-21 15:30:13 -07:00
ridiculousfish
3eae0a9b6a clang-format all C++ files
This mostly re-sorts headers that got desorted after the IWYU
application in 14d2a6d8ff.
2022-08-21 15:02:19 -07:00
ridiculousfish
c260c1259e Stop exporting kDefaultPath
This is used only within path.cpp; make it a static.
2022-08-21 14:43:28 -07:00
ridiculousfish
1d0c22b390 Remove unused 'vars' variable in path_get_path_core
This became unused deliberately in 40733ca25b.
2022-08-21 14:42:59 -07:00
Aaron Gyes
8b14ac4a9c don't even set up a fish_use_posix_spawn handler if unsupported
Also remove extern 'C' { gnu_get_libc_version }, it's no longer
used. allow_use_posix_spawn is determined true or false at
compile time.
2022-08-21 14:19:34 -07:00
Aaron Gyes
1198a05299 assert: identify the hot path
Does result in code that branches a little differently.
2022-08-21 05:55:34 -07:00
Aaron Gyes
14d2a6d8ff IWYU-guided #include rejiggering.
Let's hope this doesn't causes build failures for e.g. musl: I just
know it's good on macOS and our Linux CI.

It's been a long time.

One fix this brings, is I discovered we #include assert.h or cassert
in a lot of places. If those ever happen to be in a file that doesn't
include common.h, or we are before common.h gets included, we're
unawaringly working with the system 'assert' macro again, which
may get disabled for debug builds or at least has different
behavior on crash. We undef 'assert' and redefine it in common.h.

Those were all eliminated, except in one catch-22 spot for
maybe.h: it can't include common.h. A fix might be to
make a fish_assert.h that *usually* common.h exports.
2022-08-20 23:55:18 -07:00
Aaron Gyes
1d81ec3730 Update include-what-you-use darwin mapping file
Fixed a line or two tripped IWYU asserts about visibility
when doing e.g. a private -> public mapping but the visibility
it came up with was identical. Like the <iosfwd> to <string>
mapping, it was defined as private -> public but they're both
"public".

Added a whole bunch of lines necessary to get sane/correct
reccomendations from current IWYU on clang 10 on macOS Ventura.
Incrementally I manually added these as needed while going through
each line change IWYU wanted in each file.
2022-08-20 23:38:28 -07:00
Kid
ada9251412 More consistent --help description 2022-08-19 20:50:27 +02:00
Kid
7afd44eac8 Group string sub flags 2022-08-19 17:40:49 +00:00
Kid
d8e0cbb759 Missing -q/--query flag for builtin 2022-08-19 17:30:51 +00:00
Kid
a6a9a7cc6d Missing -v flag for command --search 2022-08-19 17:30:32 +00:00
Kid
1727ed7b5f Missing completions for builtins 2022-08-19 17:29:57 +00:00
Aaron Gyes
98692e0309 Erase __fish_config_interactive after we run it. It's yuge. 2022-08-15 11:30:47 -07:00
Fabian Boehm
7988cff6bd Increase the string chunk size to increase performance
This is a *tiny* commit code-wise, but the explanation is a bit
longer.

When I made string read in chunks, I picked a chunk size from bash's
read, under the assumption that they had picked a good one.

It turns out, on the (linux) systems I've tested, that's simply not
true.

My tests show that a bigger chunk size of up to 4096 is better *across
the board*:

- It's better with very large inputs
- It's equal-to-slightly-better with small inputs
- It's equal-to-slightly-better even if we quit early

My test setup:

0. Create various fish builds with various sizes for
STRING_CHUNK_SIZE, name them "fish-$CHUNKSIZE".
1. Download the npm package names from
https://github.com/nice-registry/all-the-package-names/blob/master/names.json (I
used commit 87451ea77562a0b1b32550124e3ab4a657bf166c, so it's 46.8MB)
2. Extract the names so we get a line-based version:

```fish
jq '.[]' names.json | string trim -c '"' >/tmp/all
```

3. Create various sizes of random extracts:

```fish
for f in 10000 1000 500 50
    shuf /tmp/all | head -n $f > /tmp/$f
end
```

(the idea here is to defeat any form of pattern in the input).

4. Run benchmarks:

hyperfine -w 3 ./fish-{128,512,1024,2048,4096}"
    -c 'for i in (seq 1000)
            string match -re foot < $f
        end; true'"

(reduce the seq size for the larger files so you don't have to wait
for hours - the idea here is to have some time running string and not
just fish startup time)

This shows results pretty much like

```
Summary
'./fish-2048     -c 'for i in (seq 1000)
          string match -re foot < /tmp/500
      end; true'' ran
  1.01 ± 0.02 times faster than './fish-4096     -c 'for i in (seq 1000)
          string match -re foot < /tmp/500
      end; true''
  1.02 ± 0.03 times faster than './fish-1024     -c 'for i in (seq 1000)
          string match -re foot < /tmp/500
      end; true''
  1.08 ± 0.03 times faster than './fish-512     -c 'for i in (seq 1000)
          string match -re foot < /tmp/500
      end; true''
  1.47 ± 0.07 times faster than './fish-128     -c 'for i in (seq 1000)
          string match -re foot < /tmp/500
      end; true''
```

So we see that up to 1024 there's a difference, and after that the
returns are marginal. So we stick with 1024 because of the memory
trade-off.

----

Fun extra:

Comparisons with `grep` (GNU grep 3.7) are *weird*. Because you both
get

```
'./fish-4096 -c 'for i in (seq 100); string match -re foot < /tmp/500; end; true'' ran
11.65 ± 0.23 times faster than 'fish -c 'for i in (seq 100); command grep foot /tmp/500; end''
```

and

```
'fish -c 'for i in (seq 2); command grep foot /tmp/all; end'' ran
66.34 ± 3.00 times faster than './fish-4096 -c 'for i in (seq 2);
string match -re foot < /tmp/all; end; true''
100.05 ± 4.31 times faster than './fish-128 -c 'for i in (seq 2);
string match -re foot < /tmp/all; end; true''
```

Basically, if you *can* give grep a lot of work at once (~40MB in this
case), it'll churn through it like butter. But if you have to call it
a lot, string beats it by virtue of cheating.
2022-08-15 20:16:12 +02:00
Fabian Boehm
40733ca25b If relative path was used, use it
This was inadvertently changed in
ed78fd2a5f

Fixes #9143
2022-08-15 20:01:50 +02:00
Aaron Gyes
c294c80214 style.fish --all improvements
clang-format (since 10) can output diagnostics which indicate
lines needing formatting with --dry-run and -Werror: the exit
code indicates if a file is correctly formatted or not.

We used to copy each .cpp file, run clang_format on the duplicate
and then `cmp` to see if there were changes made, before just
printing a line with the filename and moving the new ontop of
the original.

Now we show clang-format diagnostics which indicate which
lines will be changed, prompt for confirmation and then let
clang-format modify the files in-place without the juggling.

Looks like this: https://user-images.githubusercontent.com/291142/184561633-c16754c8-179e-426b-ba15-345ba65b9cf9.png
2022-08-14 17:57:36 -07:00
Aaron Gyes
2b2f772790 clarify "…variable is shadowed by the global variable of the same name"
Rephrase this to more explicitly indicate that the uvar actually
was successfully set. I believe the prior phrasing can leave some
ambiguity as far as wether set just failed with an error, whether it
has done anything or not.
2022-08-14 16:16:38 -07:00
Aaron Gyes
aacc71e585 builtin set: make error messages more consistent.
Now uses the same macro other builtins use for a missing -e arg,
and the error message show the short or long option as it was used.

e.g. before
    $ set -e
    set: Erase needs a variable name

after
    $ set --erase
    set: --erase: option requires an argument
    $ set -e
    set: -e: option requires an argument
2022-08-14 15:34:58 -07:00
Aaron Gyes
8416a52255 Make skeleton dir/config file create a one-time initialization thing
This moves the stuff that creates skeleton/boilerplate files to
the same place we initialize uvars for the first time or on upgrade.

Being a bit less aggresssive here theoretically makes launch a little
lighter but really I personally just found it weird I couldn't
just delete my empty config.fish file without it getting recreated
and sourced every launch.
2022-08-14 07:11:50 -07:00
Aaron Gyes
ce55114e38 git completion: use fancy ellipsis
A recenty commit was loathe to assume the unicode ellipsis character
was safe so just used '..' instead. However I noticed we actually
already do use that character elsehwere in the completions.

So, just make both spots try to somewhat carefully use it.
We do this same `string match` check on LANG in fish_job_summary.fish
2022-08-13 18:02:20 -07:00
ridiculousfish
2a0e0d6721 Remove the intern'd strings component
Intern'd strings were intended to be "shared" to reduce memory usage but
this optimization doesn't carry its weight. Remove it. No functional
change expected.
2022-08-13 12:51:36 -07:00
ridiculousfish
082f074bb1 Switch filenames from intern'd strings to shared_ptr
We store filenames in function definitions to indicate where the
function comes from. Previously these were intern'd strings. Switch them
to a shared_ptr<wcstring>, intending to remove intern'd strings.
2022-08-13 12:51:36 -07:00
Johannes Altmanninger
20a3599b10 faq.rst: correct explanation of Ctrl-R/Ctrl-S bindings in history pager 2022-08-13 21:11:54 +02:00
Johannes Altmanninger
3dfacf4b39 builtin printf: suppress warnings about unused variables
No functional change.
2022-08-13 21:11:54 +02:00
Johannes Altmanninger
c031e6f193 Highlight shell commands in history pager
This solution is quite hacky. I added a comment that suggests a better
solution, which shouldn't be hard to implement.
2022-08-13 21:11:31 +02:00
Johannes Altmanninger
b64cec1d7e Use Unicode symbols for rendering control characters in pager
The history pager will show multiline commands in single-line cells.
We escape newline characters as \\n but that looks awkward if the next line
starts with a letter. Let's render control characters using their corresponding
symbol from the Control Pictures Unicode block.

This means there is also no need to escape backslashes, which further improves
the history pager - now the rendering has exactly as many backslashes as
the eventual command.

This means that (multiline) commands in the history pager will be rendered
with the same amount of characters as are in the actual command (unless
they contain funny nonprintables).  This makes it easy for the next commit
to highlight multiline commands correctly in the history pager.

The font size for these symbols (for example ␉) is quite small, but that's
okay since for the proposed uses it's not so important that they readable.
The important thing is that the stand out from surrounding text.
2022-08-13 21:11:31 +02:00
Andy Hall
02fcc50b9a Fix typo in completions/port.fish
Replace "Specfiy" with "Specify".
2022-08-13 15:34:16 +02:00
exploide
ff716aba7f completions ip: added rudimentary completions for ip route 2022-08-13 15:31:48 +02:00
exploide
d4f142ac15 completions ip: added completions for ip link delete and some global options 2022-08-13 15:31:48 +02:00
exploide
b5e746cbd4 completions ip: remove base interface suffix for VLAN-enabled interfaces
When adding a VLAN-enabled interface, it is named like enp0s31f6.100@enp0s31f6
with the physical interface being appended behind an @.
But subsequent ip commands operate on the interface name without this suffix,
so it needs to be removed when completing interface names in __fish_ip_device
2022-08-13 15:31:48 +02:00
Fabian Boehm
18df41e5e6 Document ctrl-r harder, add something on set -x 2022-08-12 21:28:11 +02:00
Fabian Boehm
5fe43accef Add special error for set -o 2022-08-12 21:28:11 +02:00
exploide
1f5b0895fe completions dhcpcd: improved completions 2022-08-12 20:46:58 +02:00
pagedown
9c16677706 help: Handle the missing builtin aliases : and [ 2022-08-12 20:45:20 +02:00
Fabian Boehm
9492628b08 Work on the CHANGELOG
Some of the recent stuff, some examples, and put the headline feature first.
2022-08-12 18:46:53 +02:00
Fabian Boehm
8d7416048d Don't skip caret for some errors
This checked specifically for "| and" and "a=b" and then just gave the
error without a caret at all.

E.g. for a /tmp/broken.fish that contains

```fish
echo foo

echo foo | and cat
```

This would print:

```
/tmp/broken.fish (line 3): The 'and' command can not be used in a pipeline
warning: Error while reading file /tmp/broken.fish
```

without any indication other than the line number as to the location
of the error.

Now we do

```
/tmp/broken.fish (line 3): The 'and' command can not be used in a pipeline
echo foo | and cat
           ^~^
warning: Error while reading file /tmp/broken.fish
```

Another nice one:

```
fish --no-config -c 'echo notprinted; echo foo; a=b'
```

failed to give the error message!

(Note: Is it really a "warning" if we failed to read the one file we
wer told to?)

We should check if we should either centralize these error messages
completely, or always pass them and remove this "code" system, because
it's only used in some cases.
2022-08-12 18:38:47 +02:00
Fabian Boehm
232ca25ff9 Add length to the parse_util syntax errors 2022-08-12 18:38:47 +02:00
Fabian Boehm
4b921cbc08 Clamp error carets to the end instead of refusing to print
This skipped printing a "^" line if the start or length of the error
was longer than the source.

That seems like the correc thing at first glance, however it means
that the caret line isn't skipped *if the file goes on*.

So, for example

```fish
echo "$abc["
```

by itself, in a file or via `fish -c`, would not print an error, but

```fish
echo "$abc["
true
```

would. That's not a great way to print errors.

So instead we just.. imagine the start was at most at the end.

The underlying issue why `echo "$abc["` causes this is that `wcstol`
didn't move the end pointer for the index value (because there is no
number there). I'd fix this, but apparently some of
our recursive variable calls absolutely rely on this position value.
2022-08-12 18:38:47 +02:00
Fabian Boehm
c3fb927c9a Add more tests
These were correct, but littlecheck escapes quotes!
2022-08-12 18:38:47 +02:00
Fabian Boehm
c1bf06d5b1 Print "^^" for a 2-wide error 2022-08-12 18:38:47 +02:00