Commit Graph

15569 Commits

Author SHA1 Message Date
Fabian Homborg
31e2476fc8 Clarify that the variable/mode *name* is invalid
When you do

```fish
set foo-bar baz
```

"foo-baz" isn't usable as a variable *name*. When you just say the
"variable" is invalid that could also be interpreted to be a special
type of variable or something.
2022-04-08 16:38:46 +02:00
Fabian Homborg
789b2010f5 Don't use a function variable in alias
This conditionally set a function variable in an unsafe way.

If you do something like

```fish
if condition
   set -f foo bar
end
```

then, if the condition was false, $foo could still use a global variable.

In this case, alias would now fail if a variable $wraps was defined globally.

This reverts most of commit 14458682d9.

The message rewording can stay, it's *fine* (tho it'll break the
translations but then we'd need a real string freeze with a
translation team for those to be worth anything anyway, soo)
2022-04-08 16:33:27 +02:00
Aaron Gyes
7031a736a7 don't check if unsigned el->position() < 0 2022-04-07 10:16:26 -07:00
Aaron Gyes
77d02c1bd6 parse_execution: remove unused 'job' parameters 2022-04-07 09:36:54 -07:00
Aaron Gyes
8ea2be2648 decrease scope of a couple variables, prefix incr non-primitives 2022-04-07 09:25:16 -07:00
Aaron Gyes
5861358238 const size_t vals[4] 2022-04-07 09:25:16 -07:00
Aaron Gyes
b514ec5fe6 append_narrow_buffer takes const reference 2022-04-07 09:25:16 -07:00
Aaron Gyes
c06d85d175 proc.cpp: remove unused s_is_within_fish_initialization 2022-04-07 09:25:16 -07:00
Aaron Gyes
14458682d9 alias: little cleanup 2022-04-07 09:25:16 -07:00
Paul Kasemir
380c555842
completions/lxc: parse container names with numbers and other commands (#8860)
* completions/lxc: parse container names with numbers and other commands

* Revert CHANGELOG.rst

* Code Review: use multiple subcommands ability of __fish_seen_subcommand_from
2022-04-06 22:16:37 +02:00
Thom Chiovoloni
a770ff144e Make more of the functions in share/functions print error messages to stderr 2022-04-04 18:26:14 +02:00
Fabian Homborg
84bd1715d8 history: Add missing "--" for delete
Fixes #8853
2022-04-03 21:02:15 +02:00
ridiculousfish
2f1a73754b Relnote fix for #8850 2022-04-03 10:36:11 -07:00
Raymond Wong
9f98d2ec5d cmake: check for 8-bit atomic operation
Fix building on RISC-V.
Closes #8850.

Signed-off-by: Raymond Wong <infiwang@pm.me>
2022-04-03 10:20:51 -07:00
Raymond Wong
1f393c627b cmake: alter check for 64-bit atomic operation
Signed-off-by: Raymond Wong <infiwang@pm.me>
2022-04-03 10:20:51 -07:00
Johannes Altmanninger
4b5b56452b Make string syntax error location a bit more precise
String tokens are subdivided by command substitutions. Some syntax errors
can occur in the gap between two command substitutions. Make the caret point
to the start of that gap, instead of the token start.
2022-04-03 16:34:46 +02:00
Johannes Altmanninger
e717b13e75 Fix spurious syntax error on escaped $@ inside quoted command substitution
We detect use of unsupported features like $@ by scanning string tokens
as a whole. With quoted command substitution, this has false positives,
as reported in [1]. We already recursively run the same error checks on
command substitutions, so limit the remaining checks to the gaps in-between
command substitutions.

[1]: 5f94dfd094/.config/fish/README/bug.md (cannot-use-dollar-anchor-in-sed-regex-in-quoted-command-substitution)
2022-04-03 16:18:47 +02:00
Johannes Altmanninger
3e3f507012 Fix regression expanding \$()
When expanding command substitutions, we use a naïve way of detecting whether
the cmdsub has the optional leading dollar. We check if the last character was
a dollar, which breaks if it's an escaped dollar.  We wrongly expand
\$(echo "") to the empty string. Fix this by checking if the dollar was escaped.

The parse_util_* functions have a bunch of output parameters. We should
return a parameter bag instead (I think I tried once and failed).
2022-04-03 15:54:08 +02:00
Johannes Altmanninger
d87bbf9433 completions/status: fix wrong completion for test-feature
Reported in
5f94dfd094/.config/fish/README/bug.md (wrong-tab-completion-for-status-test-feature)
2022-04-03 15:54:08 +02:00
Johannes Altmanninger
1b668f5675 Don't use results of quoted command substitution in adjacent variable expansion
Given

    set var a
    echo "$var$(echo b)"

the double-quoted string is expanded right-to-left, so we construct an
intermediate "$varb".  Since the variable "varb" is undefined, this wrongly
expands to the empty string (should be "ab"). Fix this by isolating the
expanded command substitution internally. We do the same when handling
unquoted command substitutions.

Fixes #8849
2022-04-03 11:24:55 +02:00
ridiculousfish
1a0b1ae238 Rename indent test test_t to indent_test_t
This satifies VSCode's C++ extension which otherwise throws up a bogus
error. No functional change here.
2022-04-02 19:07:27 -07:00
ridiculousfish
793aff3891 Use -fno-c++-static-destructors
Static destructors cause the destructor for a global object to run when
the program exits. They are bad because:

1. Registering them takes time and memory at startup

2. Running them takes time at shutdown and also they may have weird
   interactions.

This shaves about 12k off of the binary size.

Unfortunately gcc does not support this flag.
2022-04-02 13:45:01 -07:00
ridiculousfish
448dd18685 Use head instead of dd in the read test
The read test is now failing on GitHub actions even though it passes on
my Mac. It may be due to differences in dd between these two
environments. Stop using dd and just use head.
2022-04-02 13:44:58 -07:00
ridiculousfish
108fe574a0 Finally track down that cursed read test failure
The read.fish check has a test where it limits the amount of data passed to
`read` to 8192 bytes, and verifies that fish reads exactly that amount.
This check occasionally fails on the OBS builds; it's very hard to repro a
failure locally, but I finally did it.

The amount of data written is limited via `yes` and `dd`:

    yes $line | dd bs=1024 count=(math "$fish_read_limit / 1024")

The bug is that `dd` outputs a fixed number of "blocks" where a block
corresponds to a single read. As `yes` and `dd` are running concurrently,
it may happen that `dd` performs a short read; this then counts as a single
block. So `dd` may output less than the desired amount of data.

This can be verified by removing the 2>/dev/null redirection; on a
successful run dd reports `8+0 records out`, on a failed run it reports
`7+1 records out` because one of the records was short.

Fix this by using `fullblock` so that dd will no longer count a short read
as a single block. `head` would probably be a simpler tool to use but we'll
do this for now.

Happily it's not a fish bug. No need to relnote it.
2022-04-02 11:33:07 -07:00
ridiculousfish
a80e680125 Clean up woption
1. Bravely use a real enum for has_arg, despite the warnings.

2. Use some C++11 initializers so we don't have to pass an int for this
   parameter.

No functional change expected here.
2022-04-02 11:28:30 -07:00
Johannes Altmanninger
ff72e3f154 completions/git: speed up loading git.fish when "git-foo" completions already exists
git.fish loads git-foo.fish completions.
As reported in #8831, this can be slow when the user has run something like

    complete git-foo -w 'git diff'

because git.fish runs 'complete -C "git-autofixup "' at load time.
Commit 09161761c (Complete custom "git-foo" commands from "git foo",
2021-01-24) did that to avoid adding filename completions for "git foo".
Drop that check.

This means that users who don't want filename completion for "git foo",
need to define at least one custom completion for "git-foo", like

    complete git-foo -f
2022-04-02 12:52:57 +02:00
ridiculousfish
002c2b6170 Correct a cast when measuring history file size
If the history file is larger than 4GB on a 32 bit system, fish will
refuse to read it. However the check was incorrect because it cast the
file size to size_t, which may be 32 bit. Switch to using uint64.
2022-04-01 10:25:05 -07:00
ridiculousfish
a91e1a8cab Revert "history_file_contents_t::create: remove constant comparison"
This reverts commit d7b4193978.

off_t may be wider than size_t on a 32 bit system so the comparison is
justified (though the cast is not).
2022-04-01 10:18:06 -07:00
Aaron Gyes
d7b4193978 history_file_contents_t::create: remove constant comparison
static_cast<unsigned long>(off_t len) is always < SIZE_MAX
2022-04-01 09:23:44 -07:00
ridiculousfish
338d587f2a Correct bug causing early teardown of fd_monitor
fd_monitor is used when an external command pipes into a buffer, e.g. for
command substitutions. It monitors the read end of the external command's
pipe in the background, and fills the buffer as data arrives. fd_monitor is
multiplexed, so multiple buffers can be monitored at once by a single
thread.

It may happen that there's no active buffer fill; in this case fd_monitor
wants to keep its thread alive for a little bit in case a new one arrives.
This is useful for e.g. handling loops where you run the same command
multiple times.

However there was a bug due to a refactoring which caused fd_monitor to
exit too aggressively. This didn't affect correctness but it meant more
thread creation and teardown.

Fix this; this improves the aliases.fish benchmark by about 20 msec.

No need to changelog this IMO.
2022-03-31 20:41:58 -07:00
Aaron Gyes
cd23fdac2e killall completions: fix '-procname' procs, -help, -t description 2022-03-31 20:28:25 -07:00
ridiculousfish
a960a3cde6 Emit an error if time is used past the first command in a pipeline
Fixes #8841
2022-03-31 16:14:59 -07:00
ridiculousfish
247d4b2c8f Rename EXEC_ERR_MSG to INVALID_PIPELINE_CMD_ERR_MSG
This error message was used for more than exec.
No functional change here.
2022-03-31 15:49:15 -07:00
Johannes Altmanninger
bb055c7c81 completions/code: also complete paths for --install--extension
The docs state:
code --install-extension <ext-id | path> Installs or updates an extension. The
argument is either an extension id or a path to a VSIX.
2022-03-31 17:25:15 +02:00
Fabian Homborg
f13979bfbb Move executable-check to C++
This was already apparently supposed to work, but didn't because we
just overrode errno again.

This now means that, if a correctly named candidate exists, we don't
start the command-not-found handler.

See #8804
2022-03-31 15:16:01 +02:00
Kid
90d52ee669
Complete /dev/fd in isatty (#8840)
* Complete `/dev/fd` in `isatty`

* Check `/dev/fd` existence first
2022-03-30 18:29:59 +02:00
Kid
820f8bc1af Update a few git completions 2022-03-30 18:29:21 +02:00
Fabian Homborg
f9f0ad1ef7 completions/git: Check alias definitions for an option
This allows e.g. defining

    	re = restore --staged

and then getting completions for `restore --staged`, not just `restore`.

Fixes #8843
2022-03-30 18:25:00 +02:00
Fabian Homborg
51b663787f completions/git: Complete git restore -S
This used `contains`. Let's just use `__fish_contains_opt` and pass
the short option as well.

See #8843.
2022-03-30 16:42:19 +02:00
David Adam
71a6f979a5 docs/index: reword default shell section 2022-03-29 13:33:06 +08:00
Aaron Gyes
9c96986b36 set_color: only fixup sitm/ritm/dim if NULL/empty
So we'll skip the hack should someone have a fixed terminfo or
only do it on the first set_color command.
2022-03-28 11:26:17 -07:00
Aaron Gyes
de03322073 Update date completions for newer BSDs
-d has been removed in FreeBSD 13 & monterey
-t has also been removed from date(1)
-n has been "Obsolete flag, accepted and ignored for compatibility",
   for a while, leave it out.
-R added for RFC 2822
-I added for ISO 8601

Some description changes
2022-03-28 09:26:00 -07:00
David Adam
fa2450db30 vared: avoid using local variables
The tmp and prompt variables collide with variables used as arguments.
Just avoid them entirely, at the cost of making the internals of the
functions somewhat more complicated.

Closes #8836.
2022-03-27 23:52:49 +08:00
Fabian Homborg
cc689290cd Autoload: Call the parser directly instead of going via "subshell"
This used to call exec_subshell, which has two issues:

1. It creates a command substitution block which shows up in a stack
trace
2. It does much more work than necessary

This removes a useless "in command substitution" from an error message
in an autoloaded file, and it speeds up autoloading a bit (not
measurable in actual benchmarks, but microbenchmarks are 2x).
2022-03-27 09:35:12 +02:00
Aaron Gyes
b83d8dc8c0 angular: remove sourceMappingURL comments
We don't ship source maps, so just remove these
comments to prevent the annoying 404s the server
will print out when using `fish_config`.
2022-03-26 17:14:09 -07:00
Fabian Homborg
62807c2788 fish_config: Let tabs wrap
Otherwise they would scroll off-screen for narrow windows. This was intentional.
2022-03-26 22:54:17 +01:00
Aaron Gyes
be4fa1dc1a fish_config: improve tab display
Use a heavier weight slightly larger font, remove the borders, and
prevent wrapping like:

    Binding
       s
2022-03-26 14:46:46 -07:00
Fabian Homborg
25e02ea07f fish_config: Use the same body fonts as the doc theme
Otherwise this was 100% monospace.

But since we have a specific list of fonts that we have checked, let's
use the same list instead of just adding "Helvetica" again.
2022-03-26 21:57:11 +01:00
Fabian Homborg
ff6a12e9c6 Revert "fish_config: use system-ui/sans serif for non-shell/code text"
Like the comment says: List explained in pydoctheme.css.

This also removed a number of other fonts.

This reverts commit f3cf32a085.
2022-03-26 21:53:23 +01:00
Aaron Gyes
f3cf32a085 fish_config: use system-ui/sans serif for non-shell/code text
This is nicer. It was actually using monospace fonts across
the board before.

Tweak tab rendering.
2022-03-26 13:48:23 -07:00