Commit Graph

9513 Commits

Author SHA1 Message Date
Fabian Homborg
cb7762b7c0 Move __fish_git_prompt -> fish_git_prompt
This exposes it more, since it's quite an important function.

We should do the same with the other vcs functions.

We leave a compatibility shim in place for now.
2019-02-10 14:44:50 +01:00
Aaron Gyes
34fa8ef2d2 Prefer c++11-style [[attr]] syntax over __attribute__ (attr)
Where Clang and GCC both support __attribute__ (attr) and
GCC supports [[gnu::attr]], Clang promises it will support
[[gnu::attr]]
2019-02-10 04:22:40 -08:00
David Adam
e461858964 travis: blacklist stl_tree from UBSan
Work on #2852.
2019-02-10 16:24:24 +08:00
David Adam
191e6679b3 travis: build bundled PCRE2 less often 2019-02-10 16:24:24 +08:00
David Adam
aaa6cf4492 travis: use default system clang for sanitizers 2019-02-10 16:24:24 +08:00
David Adam
74685899cb travis: turn on UBsan
Closes #2852.
2019-02-10 16:24:10 +08:00
David Adam
662708e72d src/exec: drop unused parameter in can_use_posix_spawn_for_job
Process object is not checked since 084ff64f4f.
2019-02-10 15:57:06 +08:00
Aaron Gyes
0377198fc8 Drastically improve fish completions
* complete .fish files
* --debug -> --debug-level
* add --init-command/-C
* add --debug-stack-frames/-D
* add --private/-P
* add --features/-f: lists supported features, supports foo,<TAB>
* -c now completes commands
* -d requires argument, describes 0..5
* --profile: require argument, allow file completion
2019-02-09 22:48:15 -08:00
Mahmoud Al-Qudsi
a00ef4aa2e Wrap long lines 2019-02-10 00:14:42 -06:00
Mahmoud Al-Qudsi
2445a76d2e Fix typo in yarn/npm completions helper script
Hat-tip @billyjanitsch
2019-02-10 00:09:21 -06:00
Aaron Gyes
c1504576f9 redirection.cpp: remove unused error message macro
LOCAL_PIPE_ERROR is no longer used anywhere.
2019-02-09 20:32:13 -08:00
Fabian Homborg
965fef739c docs/tutorial: Remove mention of caret (^)
While this is still technically included, the tutorial should not
steer people towards it.

[ci skip]
2019-02-09 18:48:38 +01:00
Aaron Gyes
0abcf9265e {forward,backward}-bigword on Shift-Left/Right
There was no way to do this at all without vi keybindings,
and it turns out shift-left/shift-right was available.

Fixes #1605
2019-02-07 13:11:34 -08:00
Aaron Gyes
1049bed5f8 string completions: add -e, -f, --no-empty, shorten -d's
I hope this is now complete.

Also, shorten enough descriptions to make `string match --<TAB>`
show a two column pager with 80 cols.

We really should have shown more retraint in the design of `string`,
not all of the flags required both a long and short option created.
2019-02-07 04:13:38 -08:00
Fabian Homborg
7c8b444927 Reduce default escape delay
300ms was waaay too long, and even 100ms wasn't necessary.

Emacs' evil mode uses 10ms (0.01s), so let's stay a tad higher in case
some terminals are slow.

If anyone really wants to be able to type alt+h with escape, let them
raise the timeout.

Fixes #3904.
2019-02-07 12:19:36 +01:00
Fabian Homborg
1a3471fa7d Revert "edit_command_buffer: Use variable-as-command"
This reverts commit 3c6844d4f4.

See #5625.
2019-02-07 09:47:24 +01:00
Fabian Homborg
8e60ebcd34 Revert "funced: Use variable-as-command"
This reverts commit 3253893923.

Fixes #5625.
2019-02-07 09:47:15 +01:00
Fabian Homborg
b03c62bd29 docs: Fix status is-command-substitution
The docs spoke of a short "is-command-sub" variant, which does not
exist.

Fixes #5624.

[ci skip]
2019-02-07 08:56:30 +01:00
Fabian Homborg
87e71bcde7 input: Remove useless .c_str
(Also removes some dead code)
2019-02-06 23:48:16 +01:00
Leonard Hecker
988283c717 Improved performance of the sorin theme
This improves performance of the sorin theme tremendously
for repositories with a large number of changes.
2019-02-06 12:29:52 +01:00
ridiculousfish
d4e3f49571 Correct the read_blocked comment 2019-02-05 23:21:47 -08:00
ridiculousfish
26ada583a0 Fix te_expr's flexible array member
te_expr has a flexible array member, but it's declared as size 1.
Stop declaring its size so UBSan stops complaining.

Noted in #2852
2019-02-05 23:03:59 -08:00
Brian Malehorn
6025c28efc Create function to retrieve tmpdir
`/tmp` isn't present / writeable on every system. Instead of always
using `/tmp`, try to use standard environment variables and
configuration to find a temporary directory.

Adapted from #3974, with updates based on those comments.

Closes #3845.
2019-02-05 22:18:51 -08:00
ridiculousfish
7f1dfb6284 Set CMAKE_ARCHIVE_OUTPUT_DIRECTORY
This allows Xcode archive builds to succeed.
2019-02-05 22:14:43 -08:00
ridiculousfish
23f8f1b6fb Remove some stale bits from make_pkg.sh 2019-02-05 22:14:43 -08:00
ridiculousfish
b952606430 Teach CMake Mac App build to dynamically derive the version
Populate CFBundleShortVersionString with the fish version from
git_version_gen.sh. Note this happens at build generation time, not at
build time.
2019-02-05 22:14:43 -08:00
ridiculousfish
0f5dc0b4e2 Add --stdout param to git_version_gen.sh
This causes git_version_gen.sh to print to stdout.
2019-02-05 22:14:43 -08:00
ridiculousfish
c869ab541d Remove some additional xcode references 2019-02-05 22:14:43 -08:00
ridiculousfish
807f79df03 Remove xcode instructions from README.md 2019-02-05 22:14:43 -08:00
ridiculousfish
9396f79e3e Remove xcode project
This removes the Xcode project and associated headers.
A better Xcode project can be generated via CMake:

    cmake -G Xcode /path/to/fish-shell/
2019-02-05 22:14:43 -08:00
ridiculousfish
ecb808fb39 Teach make_pkg.sh to build fish.app via cmake 2019-02-05 22:14:43 -08:00
ridiculousfish
e0396d8ef8 CMake support for building Mac app 2019-02-05 22:14:43 -08:00
ridiculousfish
eaefed434d make_pkg.sh to build with CMake instead of Xcode 2019-02-05 22:14:43 -08:00
ridiculousfish
2e542d7822 Initialize shutdown_fillthread_ to false
It was left uninitialized which was causing certain command substitutions
to exit too early.

Fixes #5616
2019-02-05 21:44:43 -08:00
David Adam
a042a4cb62 low level tests: set pwd from getcwd before starting
Fixes the tests in Debian pbuilder environments. Closes #5599.
2019-02-06 06:51:33 +08:00
Fabian Homborg
c7656e6622 Remove run_as_keepalive
Dead code, innit?
2019-02-04 17:11:34 +01:00
Fabian Homborg
ddfad001eb Remove unnecessary string copy
This called function_exists_no_autoload with a c_str().

Only that takes a wcstring, so the constructor gets called which
copies that.
2019-02-04 17:10:53 +01:00
Fabian Homborg
eb8a93f499 lint.fish: Modernize a bit
Use argparse, variable-as-command, skip missingInclude.
2019-02-04 16:58:38 +01:00
Fabian Homborg
9f469e576b tinyexpr: Prevent possible division by zero
This is possibly not actually undefined behavior because IEEE754
defines _more_ of division-by-zero, but let's be careful.

Fixes #2852.
2019-02-04 16:32:53 +01:00
David Adam
4cc168ae11 Documentation for while: note updated exit status
From updates in #4982.
2019-02-04 22:26:59 +08:00
ridiculousfish
d3fa58d621 Cleanup common.h
Remove a bunch of headers, simplify lots of code, migrate it into .cpp files.

Debug build time improves by ~3 seconds on my Mac.
2019-02-03 18:22:38 -08:00
ridiculousfish
6f682c8405 Fill io_buffer via background thread
This is a large change to how io_buffers are filled. The essential problem
comes about with code like (example):

    echo ( /bin/pwd )

The output of /bin/pwd must go to fish, not the tty. To arrange for this,
fish does the following:

1. Invoke pipe() to create a pipe.
2. Add an io_bufferfill_t redirection that owns the write end of the pipe.
3. After fork (or equiv), call dup2() to replace pwd's stdout with this  pipe.

Now when /bin/pwd writes, it will send output to the read end of the pipe.
But who reads it?

Prior to this fix, fish would do the following in a loop:

1. select() on the pipe with a 10 msec timeout
2. waitpid(WNOHANG) on the pwd proc

This polling is ugly and confusing and is what is replaced here.

With this new change, fish now reads from the pipe via a background thread:

1. Spawn a background pthread, which select()s on the pipe's read end with
a long (100 msec) timeout.
2. In the foreground, waitpid() (allowing hanging) on the pwd proc.

The big win here is a major simplification of job_t::continue_job() since
it no longer has to worry about filling buffers. This will make things
easier for concurrent execution.

It may not be obvious why the background thread still needs a poll (100 msec).
The answer is for cases where the write end of the fd escapes, in particular
background processes invoked inside command substitutions. psub is perhaps
the only important case of this (other shells typically just hang here).
2019-02-03 01:58:49 -08:00
ridiculousfish
ec29a5b913 Introduce make_pthread
This allows creating a pthread directly, which can be joined.
iothread_spawn wraps this.
2019-02-03 01:58:49 -08:00
ridiculousfish
178b72b2fd io_buffer_t becomes io_bufferfill_t
This makes some significant architectual improvements to io_pipe_t and
io_buffer_t.

Prior to this fix, io_buffer_t subclassed io_pipe_t. io_buffer_t is now
replaced with a class io_bufferfill_t, which does not subclass pipe.

io_pipe_t no longer remembers both fds. Instead it has an autoclose_fd_t,
so that the file descriptor ownership is clear.
2019-02-03 01:58:49 -08:00
ridiculousfish
084ff64f4f Allow posix_spawn more often
Now that we no longer open files after fork, we can correctly report errors
for failed file opens. So allow posix_spawn even if there's redirections.
2019-02-03 01:58:49 -08:00
ridiculousfish
2742267b9e Use dup2_list_t in posix_spawn
This simplifies the posix_spawn path and unifies it with the fork execution
path.
2019-02-03 01:58:49 -08:00
ridiculousfish
d62576ce22 Adopt dup2_list_t in fork execution path
This switches IO redirections after fork() to use the dup2_list_t,
instead of io_chain_t. This results in simpler code with much simpler
error handling.
2019-02-03 01:58:49 -08:00
ridiculousfish
6c22c8893b Switch from tee to cat in psub --fifo
Prior to this fix, we would write to a fifo via cat >$filename & .
However in some cases (and soon in all cases) we open the file before
the fork, not after. This results in a deadlock because the file open
cannot succeed until a write begins.

Switch to using tee to write to the file. Because tee opens the file itself,
fish is no longer responsible and the deadlock is resolved.
2019-02-03 01:58:49 -08:00
ridiculousfish
dbe906b79e Introduce dup2_list_t
This represents a "resolved" io_chain_t, where all of the different io_data_t
types have been reduced to a sequence of dup2() and close(). This will
eliminate a lot of the logic duplication around posix_spawn vs fork, and pave
the way for in-process redirections.
2019-02-03 01:58:49 -08:00
ridiculousfish
e3dcb01e67 Fix travis via a user-declared ctor 2019-02-02 19:13:09 -08:00