Commit Graph

11323 Commits

Author SHA1 Message Date
Johannes Altmanninger
24562a9f49 avoid allocation on lookup of $fish_trace
Looking up a variable by a string literal implicitly constructs a wcstring.
By avoiding that, we get a noticeable reduction of temporary allocations.

$ HOME=. heaptrack ./fish -c true
heaptrack stats:			# baseline
        allocations:            7635
        leaked allocations:     3277
        temporary allocations:  602
heaptrack stats:			# new
        allocations:            7565
        leaked allocations:     3267
        temporary allocations:  530
2019-12-16 16:35:41 +01:00
Johannes Altmanninger
b1144a1fde completion: fix file completion of redirection targets
This fixes a regression introduced in
6fb7f9b6b - Fix completion for builtins with subcommands
2019-12-16 12:45:39 +01:00
David Adam
5911fc94b8 littlecheck: pass close_fds to subprocess.Popen
Closes #6435.

close_fds=True is actually the default in Python 2.7 and 3.2, but not in
ancient (but still in production in Red Hat Enterprise Linux 6) Python
2.6. Enable it there as well.
2019-12-15 21:48:55 +08:00
David Adam
625db1d3f6 docs: add fish_cancel event
Introduced in 2dcaf4f5c0 as part of #5973.

[ci skip]
2019-12-14 22:36:07 +08:00
Collin Styles
012773436e Suggest unique remote branches for git-switch
From the `git-switch` documentation:

If <branch> is not found but there does exist a tracking branch in
exactly one remote (call it <remote>) with a matching name, treat as
equivalent to

   $ git switch -c <branch> --track <remote>/<branch>
2019-12-14 09:50:48 +01:00
Collin Styles
afd8fc3cdf Correctly suggest files for git-restore when --staged is present
Previously we would include all modified, deleted, and unmerged files
regardless of what options are present.
2019-12-14 09:50:48 +01:00
Collin Styles
48bf689358 Add completions for git-cherry-pick sequencer subcommands 2019-12-14 09:50:48 +01:00
Collin Styles
e7c401571b Move unique remote branches up in suggested branches for git-checkout
Currently we suggest `origin/mybranch` before `mybranch` which seems
backwards. Most of the time users will want to check out `mybranch`.
2019-12-14 09:50:48 +01:00
Collin Styles
393c9ccf99 Add missing completions for git-branch 2019-12-14 09:50:48 +01:00
David Adam
d2a7b63149 travis: turn on errors for some more serious compiler warnings
These warnings are upgraded to errors on several Open Build Service
platforms, so Travis should notify us as well.
2019-12-14 10:43:47 +08:00
David Adam
58535408b0 redirection: add a default to redirection_spec_t::oflags switch
Fixes a compiler warning/error.
2019-12-14 10:43:47 +08:00
ridiculousfish
9be77d1f9c Correctly handle "self fd redirections"
This adds a test for the obscure case where an fd is redirected to
itself. This is tricky because the dup2 will not clear the CLO_EXEC bit.
So do it manually; also posix_spawn can't be used in this case.
2019-12-13 16:51:49 -08:00
ridiculousfish
d6c71d77a9 Correctly cloexec file redirections
The IO cleanup left file redirections open in the child. For example,
/bin/cmd < file.txt would redirect stdin but also leave the file open.
Ensure these get closed properly.
2019-12-13 16:16:19 -08:00
ridiculousfish
1f83fb47ce Finish the IO cleanup.
Remove some dead code and add missing dtors.
2019-12-12 17:47:08 -08:00
ridiculousfish
5cd9de1049 Eliminate resolve_file_redirections_to_fds
Now that file redirections store FDs and not paths, this function has
nothing to do and can be removed.
2019-12-12 17:34:44 -08:00
ridiculousfish
33aff87c10 Switch io_file_t to store an fd, not a path
Prior to this fix, a file redirection was turned into an io_file_t. This is
annoying because every place where we want to apply the redirection, we
might fail due to open() failing. Switch to opening the file at the point
we resolve the redirection spec. This will simplify a lot of code.
2019-12-12 17:34:40 -08:00
ridiculousfish
af473d4d0c Introduce redirection_spec_t
Prior to this change, a process after it has been constructed by
parse_execution, but before it is executed, was given a list of
io_data_t redirections. The problem is that redirections have a
sensitive ownership policy because they hold onto fds. This made it
rather hard to reason about fd lifetime.

Change these to redirection_spec_t. This is a textual description
of a redirection after expansion. It does not represent an open file and
so its lifetime is no longer important.

This enables files to be held only on the stack, and are no longer owned
by a process of indeterminate lifetime.
2019-12-12 16:44:24 -08:00
ridiculousfish
be685faeb8 Clean up how pipe fd avoidance works
fish has to ensure that the pipes it creates do not conflict with any
explicit fds named in redirections. Switch this code to using
autoclose_fd_t to make the ownership logic more explicit, and also
introduce fd_set_t to reduce the dependence on io_chain_t.
2019-12-12 14:58:18 -08:00
Dan Martinez
4e52feb51a Have type deal with both flavors of fileless function (#6421)
* Deal with *both* types of dynamic function

* Use a guard (`--`) when `-` is an argument
2019-12-12 20:42:11 +01:00
Dan Martinez
9a3886dc2b Make type -p and type -P behave as documented (#6412)
* Make `type -p` and `type -P` behave as documented

* Recognize `-` as an additional sign of no path

Functions created via `source` (like by `alias`) cause `functions --details` to return `-`
rather than `stdin` when invoked upon them.
2019-12-12 17:09:52 +01:00
239
d23ea5f455 Added completions for Keybase commands 2019-12-12 14:16:21 +01:00
239
f1e4dc7ca8 Fixed completion for zpaq 2019-12-12 14:14:43 +01:00
Johannes Altmanninger
a446085c40 Update nmcli completions
Set variables for available connections and SSIDs only when the completion is loaded.
This is not perfect but faster than scanning for connections everytime.

Don't complete connection UUID, DBUS-PATH, ACTIVE-PATH because they are unintelligible.
Instead only complete the connection name.

See #6379

[ci skip]
2019-12-12 11:53:37 +01:00
Shun Sakai
11d529557a Update nmcli completions 2019-12-12 11:53:37 +01:00
Johannes Altmanninger
d22c7ab993 enhance sudo completions
Flag e/edit does not take an argument, so `sudo -e a` TAB would complete
subcommands.

[ci skip]
2019-12-12 09:08:42 +01:00
ridiculousfish
c0b3be9fb4 Stop storing block_io in job_t
Prior to this fix, a job would hold onto any IO redirections from its
parent. For example:

    begin
        echo a
    end < file.txt

The "echo a" job would hold a reference to the I/O redirection.
The problem is that jobs then extend the life of pipes until the job is
cleaned up. This can prevent pipes from closing, leading to hangs.

Fix this by not storing the block IO; this ensures that jobs do not
prolong the life of pipes.

Fixes #6397
2019-12-11 16:34:20 -08:00
Dan Martinez
16dc606001 Add the --short flag to type (#6403)
* Add the `--succinct` flag to `type`

* Use `echo` rather than `printf`

* Change `succinct` to `short`; print path if known

* Clean up the printing logic ever so slightly
2019-12-11 22:24:29 +01:00
Jason
0b53e51634 Remove translations for non-existent files/functions 2019-12-11 22:22:58 +01:00
Fabian Homborg
0b36d94006 docs: Link to the fish-doc and fish-tutorial pages from fish(1)
Just a brief explanation what that page is good for and how to get the
full scoop.

Fixes #5521.

[ci skip]
2019-12-11 20:59:17 +01:00
ridiculousfish
970288c854 Migrate the read limit into parser_t::libdata
It is more natural here than "on the last bufferfill."
2019-12-11 11:50:52 -08:00
Fabian Homborg
ff4498ceec CHANGELOG: Add some nice bits
[ci skip]
2019-12-11 20:50:23 +01:00
Johannes Altmanninger
cc7ae03070 prompt: don't consider SIGPIPE a failure
[ci skip]
2019-12-11 11:32:58 +01:00
Johannes Altmanninger
94b5720343 prompt: remove fallback for $fish_color_host
This was mostly dead, since $fish_color_host is set to normal in
__fish_config_interactive. The assignment was only used if the user
explicitly unsets fish_color_host (which they shouldn't, really).
Anyway it's weird to use cyan, use normal instead.
[ci skip]
2019-12-11 11:32:58 +01:00
Johannes Altmanninger
2f1a5e65d8 prompt: don't set default colors twice
The colors are set in __fish_config_interactive before the prompt is
painted for the first time.

Also initialize the $fish_color_status for the (pipe) status, bump the
version for that.
[ci skip]
2019-12-11 11:32:58 +01:00
Johannes Altmanninger
3f10da0d01 Persist new zero-length universal variables
Because of default initialization to an empty list, code that relies on
set -U __fish_init_3_x was run every time.
2019-12-11 11:32:58 +01:00
ridiculousfish
0b1af1ace4 Correct the use of the constructed pointer in job lineage
This was always being set to a different pointer. Ensure the root job
shares its constructed pointer with its children.
2019-12-10 18:32:56 -08:00
ridiculousfish
1e15aa4c4a Correctly style io_chain_t::print 2019-12-10 17:21:03 -08:00
ridiculousfish
0573e95b03 Resurrect io_print 2019-12-10 17:18:37 -08:00
Johannes Altmanninger
d4a3b30b73 prompt: move status to the right in classic_status sample prompt
This is consistent with the other prompts that include status.

[ci skip]
2019-12-11 01:19:12 +01:00
Johannes Altmanninger
6902459566 prompt: don't print status of last process in pipe twice
If a command fails, print the pipestatus in red instead of yellow and
don't print the status of the last process again. See #6375.

Also use $fish_color_status for coloring status consistently.

Also use __fish_pipestatus_with_signal to print SIGPIPE instead
of a numeric code on e.g.: yes | less +q

[ci skip]
2019-12-11 01:19:12 +01:00
ridiculousfish
eaa87ff885 Correct a comment
A comment claimed that 0 was STDOUT_FILENO. In fact this should be 1.

Also default the fd for pipe_or_redir_t to -1, as 0 is not a sensible
default.
2019-12-10 16:14:34 -08:00
Johannes Altmanninger
6b2addd9f3 prompt: don't print pipestatus if only the last process failed
Example: ps | grep something

[ci skip]
2019-12-10 22:35:24 +01:00
Fabian Homborg
6da4b682db docs: Separate scripting/interactive sections
[ci skip]
2019-12-10 21:05:21 +01:00
Fabian Homborg
b491e2bbfc docs: Turn some sections into subsections
[ci skip]
2019-12-10 21:01:09 +01:00
Fabian Homborg
15c6d8fd4c completions/zstd: Remove code to figure out number of CPUs
This purported to need python > 3.4, but used anypython.

Plus it's not super useful anyway since it can easily be told to
use *all* cpus, so there's no need to set it to the precise number.

See #6400.

[ci skip]
2019-12-10 20:20:21 +01:00
Fabian Homborg
ea7868988a docs: Remove "simple"
This just reads condescending. The user can decide for themselves how
simple something is.

[ci skip]
2019-12-10 19:05:37 +01:00
Fabian Homborg
eb7837113f docs: File completion can indeed be enabled again
[ci skip]
2019-12-10 19:03:44 +01:00
Fabian Homborg
8a5eda3e9b docs: Some nits
[ci skip]
2019-12-10 18:47:46 +01:00
Fabian Homborg
2b6b6a0de0 docs: Link tutorial immediately 2019-12-10 18:47:14 +01:00
Fabian Homborg
d05b7614dd Reorder setup instructions
First tell them how to install (though we don't actually do that right
now), then tell them how to start it, and only *then* tell them how to
make it the default or uninstall it.

Just seems sensible to try it first then delete it.
2019-12-10 18:35:25 +01:00