Commit Graph

14493 Commits

Author SHA1 Message Date
Fabian Homborg
0e06a53dff help: Add sections directly via the <span id>
This should add all the sections that aren't linked internally,
including "identifiers".

(also give up on the line breaking because it makes it annoying to do
automatically)

Fixes #8245.
2021-08-22 13:14:59 +02:00
Rosen Penev
a9b4127f68 clang-tidy: run through normal checks
There's a .clang-tidy file in here.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-21 21:59:05 +02:00
Fabian Homborg
70e3e0beac Also remove ephemeral item if command is effectively empty
Fixes #8232.

Note that this needed to have expect_prompt used in the pexpect test -
we might want to add a "catchup" there so you can just ignore the
prompt counter for a bit and pick it back up later.
2021-08-20 19:38:16 +02:00
Rosen Penev
b748417af7 clang-tidy: replace size comparisons with empty
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-20 18:32:45 +02:00
Rosen Penev
1af9e5d21e clang-tidy: simplify two bool returns
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-20 18:32:15 +02:00
Fabian Homborg
fe71e62a68 help: Update sections
This was semi-automated with

```fish
for file in $argv
    set -l varname (string replace -r '.*/(.*).html' '$1' -- $file | string escape --style=var)pages
    set -l sections (string replace -rf '.*class="headerlink" href="#([^"]*)".*' '$1' <$file)

    echo set -l $varname $sections
end
```

(where $argv contains the path to faq, fish_for_bash_users,
interactive, language and tutorial.html)

Building help.fish at compile time would work, but only for users who
build the docs.
2021-08-20 17:40:57 +02:00
Fabian Homborg
d4f7e25584
Replace strerror/sys_errlist after fork with our own errors (#8234)
* Remove safe_strerror, safe_perror and safe_append

This no longer works on new glibcs because they removed sys_errlist.

So just hardcode the relevant errno messages (and phrase them better).

Fixes #4183.

Co-authored-by: Johannes Altmanninger <aclopte@gmail.com>
2021-08-20 17:17:01 +02:00
Rosen Penev
90f006b1cd clang-tidy: use delete
The clang warning for pending_signals_t was about the operator=
return type being wrong (misc-unconventional-assign-operator).

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-20 01:33:33 +02:00
Johannes Altmanninger
5de05a810c Tell clang-tidy that expander_t::stage_variables intentionally takes values
We don't want to convert the input to a "wcstring &" because
"stage_variables" needs to have the same type as other stages, so we
can use it in a loop. Communicate that to clang-tidy.

We also don't want to take "wcstring &&". As the Google style guide
states, it's not really beneficial here, and it potentially hurts
readability because it's a relatively obscure feature.
The rest of our code contains a bunch of && parameters.  We might
want to get rid of some of them.

Closes #8227
2021-08-20 01:21:21 +02:00
Rosen Penev
ffa3e0b4f4 convert const ref to value
clang-tidy wrongly sees an std::move to a const ref parameter and
believes it to be pointless. The copy constructor however is deleted.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-20 01:16:24 +02:00
Rosen Penev
4ea5189c4f clang-tidy: const reference conversions
These are only read from.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-20 01:15:48 +02:00
Rosen Penev
f9af33f223 clang-tidy: remove pointless virtual
override is already used.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-20 01:15:23 +02:00
Rosen Penev
faf51e0693 clang-tidy: use for range loops
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-20 01:14:25 +02:00
David Adam
dffc84712a CHANGELOG: work on 3.4.0 2021-08-18 22:23:32 +08:00
ridiculousfish
2ca66cff53 Disable job control inside command substitutions
This disables job control inside command substitutions. Prior to this
change, a cmdsub might get its own process group. This caused it to fail
to cancel loops properly. For example:

    while true ; echo (sleep 5) ; end

could not be control-C cancelled, because the signal would go to sleep,
and so the loop would continue on. The simplest way to fix this is to
match other shells and not use job control in cmdsubs.

Related is #1362
2021-08-18 22:20:03 +08:00
Mahmoud Al-Qudsi
d27f477ba6 Fix truncated completions for pkg install <foo>
The same hack that is used for `pkg remove <foo>` is required here, too.
Due to the massive number of results, we use `head -n 250` to prevent
the completion from hanging or the shell from being overencumbered by
too many possibe completions. However, this would only generate matches
for any of the first 250 packages, rather than printing the first 250
packages that match.

[ci skip]
2021-08-18 00:20:08 -05:00
Mahmoud Al-Qudsi
3291102045 Refactor deferred_process handling to be more clearly safe
The previous layout confused me for a minute as it suggested it was
possible for `pipe_next_read` to be moved twice (once in the first
conditional block, then again when the deferred process conditional
called `continue` - if and only if the deferred process *was* the last
process in the job. This patch clarifies that can't be the case.
2021-08-17 20:10:19 -05:00
Mahmoud Al-Qudsi
c014c23662 Fix undefined behavior in closing a moved pipe
`pipe_next_read` is moved in the body of the loop, and not
re-initialized the last go around. However, we call
`pipe_next_read.close()` after the loop, which is undefined behavior (as
it's been moved).

Best case scenario, the compiler passed the address of our copy of the
struct to `exec_process_in_job` and beyond, it went out of scope there,
the value of `fd` was set to closed (minus one), and we explicitly call
`.close()` again, in which case it does nothing.

Worst case scenario, the compiler re-uses the storage for the now-moved
struct for something else and our call to `.close()` ends up closing
some other value of `fd` (valid or invalid) and things break.

Aside from the fact that we obviously don't need to close it since it's
not assigned for the last process in the job, it's a RAII object so we
don't have to worry about manually closing it in the first place.
2021-08-17 19:52:15 -05:00
Mahmoud Al-Qudsi
57615504d0 Eliminate variable unused after refactor of wcstringutil.cpp 2021-08-17 19:23:13 -05:00
Mahmoud Al-Qudsi
426fa82f8f Fix recently broken escape_code_length() result
`escape_code_length()` was converted from returning a `size_t` to
returning a `maybe_t<size_t>` but that subtly broke all existing call
sites by forcing all input to go through the slow path of assuming a
zero-length escape sequence was found.

This is because all callers predicated their next action on what amounts
to `if (escape_code_length(...))` which would correctly skip the slow
path when `escape_code_length` returned zero, but after the conversion
to `maybe_t` contained not `maybe_t::none()` but rather
`maybe_t::some(0)` due to coercion of the result from the `size_t` local
`esc_seq_len` to the `maybe_t<size_t>` return value - which, when
coerced to a boolean returns *true* for `maybe_t::some(0)` rather than
false.

The regression was introduced in 7ad855a844
and did not ship in any released versions so no harm, no foul.
2021-08-17 19:04:10 -05:00
Mahmoud Al-Qudsi
daa366eb5a maybe.h: reference header new
This is required for the usage of placement new. Not an issue for fish
as it gets picked up from elsewhere, but it lets one use it in a C++
test directly this way.
2021-08-17 18:57:16 -05:00
Rosen Penev
ba91b39715 replace push_back with emplate_back
The latter forwards the arguments directly.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2021-08-17 18:56:19 -05:00
Fabian Homborg
c055e3ae66 docs: Reword feature flags chapter 2021-08-17 17:32:41 +02:00
Fabian Homborg
7df833acc1 MOAR CHANGELOG 2021-08-17 16:31:22 +02:00
Fabian Homborg
6c5c8e03c5 Move the numeric locale tests to a different file
This lets us check for locales once, and to have littlecheck mark the
test as skipped.
2021-08-17 15:36:07 +02:00
Fabian Homborg
102853e0e0 Work on the CHANGELOG
Adding some examples seems helpful, there's no need to be super terse.
2021-08-17 13:52:12 +02:00
Fabian Homborg
e9ee1820d6 Default emoji width to 2 for iTerm
Hallelujah, they switched to Unicode 9.

See #8220.
2021-08-17 13:30:34 +02:00
David Adam
a8fddf3d9b add tests for zero-index expressions
See 5326462116 / #8213.
2021-08-17 12:41:03 +08:00
aca
321fd74de0 edit_command_buffer: use "command" to ignore any functions with the same name 2021-08-17 06:24:09 +02:00
David Adam
ef53605fa9 CHANGELOG: work on 3.4.0 2021-08-16 22:01:33 +08:00
David Adam
ff8f26e65a funced: suggest saving functions when an editor is used 2021-08-16 21:45:23 +08:00
David Adam
8dd4c67db1 funcsave: edit the whole file containing a function
Many functions ship in files with helper functions, and it is useful to
edit those too.

Closes #391.
2021-08-16 21:45:22 +08:00
David Adam
52eff27239 funced: don't source or save unmodified files
If funced is just used to inspect a function, there's no need to write
it to storage or to reload it.
2021-08-16 21:44:43 +08:00
David Adam
911269c4a9 funcsave: avoid the edited function's path being a temporary file
As functions know where they are loaded from now, there is no point in
them being marked as loaded from a temporary file that has been removed.
Source the function via a redirect instead.
2021-08-16 21:44:43 +08:00
David Adam
a40e60b45b funced: minor grammar fixes to documentation 2021-08-16 21:44:43 +08:00
Mahmoud Al-Qudsi
0a4f80ec41 Add more tests for literal zero indexes 2021-08-15 13:48:41 -05:00
Mahmoud Al-Qudsi
5326462116 Catch more zero-index expressions
This expands the sanity check for literal zero indexes that was not
updated when range expansions was introduced.

Closes #8213
2021-08-15 13:48:41 -05:00
Fabian Homborg
7f34b8ab53 docs: Add copy buttons to all the codeblocks
This uses a bit of javascript to add copy buttons, so you can directly
copy all the code in a given block to the clipboard!

For codeblocks without prompts, it just copies all the code, for
blocks with prompts, it copies all the lines after prompts, under the
assumption that that's the code to be executed.

It would give you *all* the lines, so the output wouldn't be
interleaved like it is in the html, but good enough.

The buttons appear on hover, so they aren't usable on phones, but
since you won't really have a clipboard on phones and I have no idea
how to make them not always in front of the text otherwise: Eh.

I'm not in love with the javascript here, but it'll do.
2021-08-15 20:09:49 +02:00
Fabian Homborg
e2fef7b392 CHANGELOG 2021-08-14 11:30:30 +02:00
Fabian Homborg
c4593828f4
commandline: Add --is-valid option (#8142)
* commandline: Add --is-valid option to query whether it's syntactically complete

This means querying when the commandline is in a state that it could
be executed. Because our `execute` bind function also inserts a
newline if it isn't.

One case that's not handled right now: `execute` also expands
abbreviations, those can technically make the commandline invalid
again.

Unfortunately we have no real way to *check* without doing the
replacement.

Also since abbreviations are only available in command position when
you _execute_ them the commandline will most likely be valid.

This is enough to make transient prompts work:

```fish
function reset-transient --on-event fish_postexec
    set -g TRANSIENT 0
end

function maybe_execute
    if commandline --is-valid
        set -g TRANSIENT 1
        commandline -f repaint
    else
        set -g TRANSIENT 0
    end
    commandline -f execute
end

bind \r maybe_execute
```

and then in `fish_prompt` react to $TRANSIENT being set to 1.
2021-08-14 11:29:22 +02:00
Fabian Homborg
8767f873eb CHANGELOG set -q change 2021-08-14 10:59:49 +02:00
mtoohey31
703a717660 completion: support --no prefixes for mpv flag options 2021-08-14 10:56:23 +02:00
Fabian Homborg
eee38836cf set -q: Return 255 if no variable name was passed
Previously this strictly returned the number of unset variables. So if
no variable was given, it would return *true*, which is highly
suspect.
2021-08-14 10:55:21 +02:00
Fabian Homborg
35c53a94b5 docs: Remove stuff from globbing
That `find` example is a bit dated and awkward, and doesn't really fit
the section.

We also don't want to point people to `?` because we want to remove it.
2021-08-11 18:42:21 +02:00
Fabian Homborg
013f98a5b3 docs: Double-re-extra mention bash vs fish globbing
And in the section we now point people towards!
2021-08-11 18:41:37 +02:00
Fabian Homborg
b5e5732be1 Point wildcard error at a more specific help section
"Expansion" covers *all* the expansions, that's a bit of a handful.

Directly point people towards globbing.
2021-08-11 18:40:37 +02:00
ridiculousfish
b0b6a585a8 Support Apple_Terminal in fish_vi_cursor
This enables it unconditionally, as tests show that the cursor escapes
are ignored before 10.12.

Fixes #8167
2021-08-10 13:23:08 -07:00
ridiculousfish
fdf8f17397 Stop using thread local vectors
These don't build on macOS 10.9, and are unnecessary anyways.
Thread local variables should only be simple primitives.
2021-08-10 13:07:13 -07:00
Johannes Altmanninger
7b55c0edb4 completions/git: finish completions for git bisect 2021-08-10 21:01:39 +02:00
Johannes Altmanninger
96e665f9ec __fish_complete_subcommand: (re)move confusing comment 2021-08-10 21:01:39 +02:00