Commit Graph

11352 Commits

Author SHA1 Message Date
Mahmoud Al-Qudsi
abc2468c70 Add alternate patch to support in-tree CMake Makefile builds
This patch keeps the existing `make` shims via `GNUmakefile` and
`BSDmakefile` but also resolves the issue reported in #6264 with
CMake-generated `Makefile` overwriting the extant `Makefile` causing the
source directory to become dirty once again.

Closes #6264
2019-12-18 21:35:46 -06:00
Mahmoud Al-Qudsi
aeaf2f93e2 Revert "Remove Makefile(s)"
This reverts commit 326f5586de.

See discussion in #6264.
2019-12-18 21:27:09 -06:00
Rosen Penev
9936362599 common.cpp: Don't always include cxxabi.h
cxxabi.h is not available with LLVM's libcxx
2019-12-18 21:03:51 -06:00
Mahmoud Al-Qudsi
e5e66ac6d7 Merge branch 'time' 2019-12-18 21:00:00 -06:00
Mahmoud Al-Qudsi
103726767c [time] Convince GCC control flow does not reach end of function 2019-12-18 20:53:38 -06:00
Mahmoud Al-Qudsi
704a90deec Rename time unit enum to please gcc 2019-12-18 20:48:02 -06:00
Mahmoud Al-Qudsi
be37656067 Support time -v for detailed time output
This breaks down the usage into fish vs external processes.
2019-12-18 20:28:15 -06:00
Mahmoud Al-Qudsi
1ed5e7e478 Dynamically choose units for time output 2019-12-18 20:27:12 -06:00
Mahmoud Al-Qudsi
5956270015 Add time builtin that understands fish script and external executables
This now works:

```fish
function foo
    for n in (seq 1 100000)
        test $n -eq 42
    end
end

time foo
```
2019-12-18 20:27:08 -06:00
Mahmoud Al-Qudsi
364929e46e Disown first-run python completions generation
Closes #6269.
2019-12-18 14:12:49 -06:00
Jason
48bf3a4907 Delete __fish_sgrep.fish 2019-12-18 13:17:54 -06:00
Mahmoud Al-Qudsi
6dc8a1d3a7 Partially address #6340 (escape files starting with -)
This prefixes files beginning with `-` with a `./` when generating
completions *in fish code*. Standard completions for directory listings
generated by the C++ directory traversal code are not afected by this
patch.

Most fish completions defer to `__fish_complete_suffix` to generate the
file/directory completions, these *will* be corrected.
2019-12-18 13:13:23 -06:00
Mahmoud Al-Qudsi
92401d8ebb Fix unused return result hack to work on macOS/GCC 7.4+
As of GCC 7.4 (at least under macOS 10.10), the previous workaround of
casting a must-use result to `(void)` to avoid warnings about unused
code no longer works.

This workaround is uglier but it quiets these warnings.
2019-12-18 12:43:13 -06:00
Mahmoud Al-Qudsi
60670999ad Fix mismatched wchar_t sign comparison errors on some platforms
The C++ spec (as of C++17/n4713) does not specify the sign of `wchar_t`,
saying only (in section 6.7.1: Fundamental Types)

> Type wchar_t shall have the same size, signedness, and alignment
> requirements (6.6.5) as one of the other integral types, called its
> underlying type.

On most *nix platforms on AMD64 architecture, `wchar_t` is a signed type
and can be compared with `int32_t` without incident, but on at least
some platforms (tested: clang under FreeBSD 12.1 on AARCH64), `wchar_t`
appears to be unsigned leading to sign comparison warnings:

```
../src/widecharwidth/widechar_width.h:512:48: warning: comparison of
integers of different signs: 'const wchar_t' and 'int32_t' (aka 'int')
[-Wsign-compare]

    return where != std::end(arr) && where->lo <= c;
```

This patch forces the use of wchar_t for the range start/end values in
`widechar_range` and the associated comparison values.
2019-12-18 12:32:04 -06:00
Mahmoud Al-Qudsi
d90d4f849c Force symlink creation in realpath tests
If an earlier test was aborted, the symlink would still be present and
the subsequent run will fail to create the symlink as it wasn't forced.
2019-12-18 12:31:24 -06:00
ridiculousfish
e52433d6fe Fix gcc warnings harder 2019-12-17 19:51:00 -08:00
ridiculousfish
7ab373fbbd Fix some gcc warnings 2019-12-17 19:22:43 -08:00
ridiculousfish
311f47d683 Remove an errant fprintf from the tests 2019-12-17 18:26:57 -08:00
ridiculousfish
d4daa28690 Correctly set the exit status in block and function processes
Previously, if the user control-C'd out of a process, we would set a
bogus exit status in the process, but it was difficult to observe this
because we would be cancelling anyways. But set it properly.
2019-12-17 18:19:38 -08:00
ridiculousfish
b3d2cdc0ff Unify parse_execution_result_t and eval_result_t again
Do other cleanup to better express the difference between cancellation
and control flow.
2019-12-17 18:12:49 -08:00
ridiculousfish
b82b111e55 Revert "Unify parse_execution_result_t and eval_result_t"
This reverts commit c011f3a8e9.

There is a bug where cancellation is being reported for normal control
flow, not just for SIGINT.
2019-12-17 17:31:18 -08:00
ridiculousfish
c011f3a8e9 Unify parse_execution_result_t and eval_result_t
These are just the same thing now; make everything eval_result_t.
2019-12-17 16:52:15 -08:00
ridiculousfish
a58286baea Remove parse_execution_skipped
This was unused.
2019-12-17 16:44:42 -08:00
ridiculousfish
ebc262cfba Fix sporadic cancellation test failures
If a Control-C is received during expanding a command substitution, we
may execute the job anyways, because we do not check for cancellation
after the expansion. Ensure that does not happen.

This should fix sporadic test failures in the cancellation unit test.
2019-12-17 16:42:14 -08:00
ridiculousfish
72de8768d9 Remove RUNNING_IN_XCODE checks
This is never set any more.
2019-12-17 16:19:12 -08:00
ridiculousfish
09f8e05b80 Clean up the return type of parser_t::eval
parser_t::eval indicates whether there was a parse error. It can be
easily confused with the status of the execution. Use a real type to
make it more clear.
2019-12-17 16:16:43 -08:00
ridiculousfish
4f3b3f7d61 Rename GIT_DIR to FISH_BASE_DIR in git_version_gen.sh
$GIT_DIR is interpreted by git as an environment variable, pointing at the
.git directory. If git_version_gen.sh is run in an environment with an
exported GIT_DIR, it will re-export GIT_DIR to point at the fish source
directory. This will cause git operations to fail.

This could be reproduced as building fish as part of an interactive rebase
'exec' command. git_version_gen.sh would always fail!
2019-12-16 19:18:56 -08:00
ridiculousfish
8bf9f52461 Always detach new pthreads
There are no longer any calls to pthread_join. Just make all pthreads
detached.
2019-12-16 14:08:46 -08:00
Fabian Homborg
3b2dbb99ec po: s/__fish_git_prompt/fish_git_prompt/g 2019-12-16 19:53:10 +01:00
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