Commit Graph

3193 Commits

Author SHA1 Message Date
ridiculousfish
8301aa9929 Add a test that nohup works
If fish is invoked with nohup, then its children should be nohup too.
2020-08-10 12:26:30 -07:00
David Adam
d8eb7fc46d fish: support -o short option correctly
Closes #7254.
2020-08-10 13:37:29 +08:00
ridiculousfish
aaa59d377e Remove a bunch of #ifdef'd out code 2020-08-09 15:06:50 -07:00
ridiculousfish
c1abb474c2 Remove some dead code and enable a test 2020-08-09 15:05:16 -07:00
Johannes Altmanninger
563a2d824c fish_indent: indent comments before line continuation
See #7252
2020-08-09 23:59:30 +02:00
Johannes Altmanninger
f8f32628a6 fish_indent: no extra newline at comment after pipe
Fixes the unstable case in #7252
2020-08-09 23:59:30 +02:00
ridiculousfish
f6c1ef58df Indent continuations after | and &&
This indents continuations after pipes and conjunctions if they contain
a newline.

Example:

    cmd1 &&
        cmd2

But it avoids the "double indent" if it indented unconditionally:

    cmd1 | begin
        cmd2
    end

More work towards improving #7252
2020-08-09 12:22:15 -07:00
ridiculousfish
9a53bf7d56 fish_indent: indent line continuations
For example:

    cmd \
        arg

Fixes one case from #7252
2020-08-09 12:22:14 -07:00
ridiculousfish
e2a26b2fdf fish_indent: Correct certain comment indenting
Prior to this change, when emitting gap text (comments, newlines, etc),
fish_indent would use the indentation of the text at the end of the gap.
But this has the wrong result for this case:

    begin
    command
    # comment
    end

as the comment would get the indent of the 'end'. Instead use the indent
computed for the gap text itself.

Addresses one case of #7252.
2020-08-09 12:22:05 -07:00
ridiculousfish
2676926902 Use unordered_map instead of map in lru
They have the same iterator invalidation guarantees, and unordered_map
benchmarks as faster for wcstring.
2020-08-08 15:32:06 -07:00
ridiculousfish
91955c1371 Don't eagerly fetch the current time in autoloading
The call to now() is not always necessary and shows up in traces.
2020-08-08 15:30:04 -07:00
ridiculousfish
68275e7f58 Simplify parser_keywords_is_reserved 2020-08-08 15:04:52 -07:00
Fabian Homborg
2cdd6df257 fish_indent: Add a "--check" option to only test indentation
Fixes #7251.
2020-08-08 20:23:14 +02:00
Fabian Homborg
103a4ece81 Add parens to silence warning
This triggered -Wparentheses in gcc 10.1.0
2020-08-08 09:14:47 +02:00
ridiculousfish
3dcb39f8ec Improve codegen of generation_list_t::operator==
Bizarrely comparing three integers showed up heavy in traces. This
reduces the time in seq_echo by about 500 msec.
2020-08-07 23:15:09 -07:00
ridiculousfish
5bee1e3e1f Avoid an errant copy in autoload_t::resolve_command
The ternary expression was causing the list of paths (e.g.
$fish_function_path) to be copied. Avoid that copy with an if statement.

This reduces the time spent in try_autoload from 2.4 sec to 961ms on
the seq_echo benchmark run 1024 times, about 5% improvement.

Oh, C++...
2020-08-07 22:34:42 -07:00
ridiculousfish
2cd336376e Refactor process_mark_finished_children
Reduce the level of nesting and the loop complexity.
2020-08-07 12:34:53 -07:00
ridiculousfish
26fda2bf0d Improve some formatting in proc.h 2020-08-07 11:38:47 -07:00
ridiculousfish
557fe57deb Close the file descriptor returned by mkstemp 2020-08-06 19:12:15 -07:00
ridiculousfish
206b2d0a26 Simplify topic monitoring
The topic monitor allows a client to wait for multiple events, e.g. sigchld
or an internal process exit. Prior to this change a client had to specify
the list of generations and the list of topics they are interested in.
Simplify this to just the list of generations, with a max-value generation
meaning the topic is not interesting.

Also remove the use of enum_set and enum_array, it was too complex for what
it offered.
2020-08-06 19:01:30 -07:00
Johannes Altmanninger
f7ef91ae2a Use mkstemp over mktemp to silence warning 2020-08-06 21:24:26 +02:00
Johannes Altmanninger
b947e360db Allow newlines after && and ||
We do the same for pipes (#1285). This matches POSIX sh behavior.
2020-08-06 21:24:26 +02:00
ridiculousfish
e6616d7017 Correct a misspeeling 2020-08-06 11:51:08 -07:00
Soumya
539e6fe8b1 Return no status from successful variable assignments 2020-08-05 12:23:49 -07:00
Soumya
8dd2d4f15d Change builtins to return maybe_t<int> instead of int 2020-08-05 12:23:49 -07:00
Soumya
a2b2bcef6e Add a $status_generation variable that's incremented for each interactive command that produces a status.
This can be used to determine whether the previous command produced a real status, or just carried over the status from the command before it. Backgrounded commands and variable assignments will not increment status_generation, all other commands will.
2020-08-05 12:23:49 -07:00
Johannes Altmanninger
8d3b66fb52 Reflow comment 2020-08-04 21:44:59 +02:00
Johannes Altmanninger
64601fd4d3 Reformat CPP files 2020-08-04 21:44:59 +02:00
ridiculousfish
81f9f51bcb Incorporate widecharwidth changes for narrow emoji
This pulls in widechar_width.h from commit 7e9dfdaf05059b3f. The big change
here is that some characters which were previously marked as widened in 9
are now marked as unconditionally narrow; this includes some randoms like
hot pepper (U+1F336) but more importantly all of the regional indicators,
which affects how flags are rendered.

If you put two regional indicators together, you get a flag emoji. It's
unclear what the width of this flag emoji should be; Terminal and iTerm2
renders it as width 1, while kitty renders it as width 2. This is
unaffected by fish_emoji_width because the flag does not have an assigned
codepoint, it is a pair of codepoints.

The regional indicators are marked as "neutral" in EastAsianWidth.txt which
means they conceptually have width 1. So two of them have width 2. So now
we assume that flags are rendered as width 2.

This fixes #7237, for terminals that render flags as width 2 (but not 1,
unfortunately, which includes iTerm2 and Terminal.app).
2020-08-04 12:40:46 -07:00
ridiculousfish
c9bcb52fe9 Pull in later widecharwidth
This pulls in widechar_width.h from commit d4e75d5bb1930291223d1.
This is a "rebuild with latest data" before we attempt a risky bugfix.
The idea here is that bisecting can separate whether any regression is
due to using the latest Unicode data, or the bug fix.
2020-08-04 12:21:33 -07:00
ridiculousfish
fc5067ca33 Fix an uninitialized variable warning on gcc 6 2020-08-04 11:01:31 -07:00
ridiculousfish
976ed6d2e8 Fix std::hash overload on g++ 6
Fixes a build error introduced in 6eab9275d0.
2020-08-04 10:56:14 -07:00
ridiculousfish
6eab9275d0 Cache resolved colors when outputting to the screen
Prior to this change, fish would "resolve" highlight specs to rgb colors
right before use. This requires a series of variable lookups; profiling
showed 30% of draw time was spent here.

Switch to caching these (within a single redraw only).
2020-08-03 17:34:27 -07:00
ridiculousfish
87d049edd8 Remove redirect_tty_output call from tcgetattr return
tcgetattr cannot return EIO.
2020-08-03 16:42:27 -07:00
ridiculousfish
f1402ac7a3 Eliminate some uses of current_data in the reader 2020-08-03 15:41:12 -07:00
ridiculousfish
272ca37582 Remove most dynamic reader configuration
Have the reader accept a constant configuration object, which controls
whether autosuggestions, etc. are enabled. These things don't change
dynamically.
2020-08-03 15:02:44 -07:00
ridiculousfish
fadd429348 Make the shell test function a toggle
We either perform fish syntax checking or we don't; there's no reason
to specify a function pointer here.
2020-08-03 14:31:09 -07:00
ridiculousfish
7304815736 Make shell highlighting a toggle instead of a function parameter
Remove the ability to specify the "highlight function." The reader
always highlights via shell highlighting, or doesn't.
2020-08-03 14:10:37 -07:00
ridiculousfish
18c7c46657 Remove highlight_universal
This was an attempt to offer syntax highlighting for `read` when shell
highlighting is not enabled, but it hardly did anything.
2020-08-03 13:41:41 -07:00
ridiculousfish
f94a6a74f0 Remove fish_color_match support
fish_color_match is a variable which controls syntax highlighting for
matching quotes and parens, but only with interactive `read` with shell
highlighting disabled. It seems unlikely that anybody cares about this.
2020-08-03 13:36:47 -07:00
Olivier FAURE
e7f0b5801d Add forward-single-char input command
This allows users to add custom keybindings to autocomplete only one
character at a time.

Resolves https://github.com/fish-shell/fish-shell/issues/4984
2020-08-01 12:09:31 +02:00
Olivier FAURE
6778d04aa5 Add or keybind input function 2020-08-01 12:09:31 +02:00
ridiculousfish
81a39be0bb Support explicitly separated output on stderr
In principle this would allow 'string split' or whatever to output to
stderr and not lose the item separation. In practice this is not used
but it fixes a TODO.
2020-07-30 23:00:34 -07:00
ridiculousfish
bcfc54fdaa Do not buffer builtin output if avoidable
builtins output to stdout and stderr via io_streams_t. Prior to this fix, it
contained an output_stream_t which just wraps a buffer. So all builtin output
went to this buffer (except for eval).

Switch output_stream_t to become a new abstract class which can output to a
buffer, file descriptor, or nowhere. This allows for example `string` to stream
its output as it is produced, instead of buffering it.
2020-07-30 22:45:44 -07:00
ridiculousfish
68092c5d21 Bravely have read_blocked return after first read
In commit fd6d814ea4, read_blocked was changed to read until EOF
or the full amount requested is returned. Switch this to returning
as soon as any data is available, which was the behavior prior to
fd6d814ea4.

This will allow builtin_string to output data in a "streaming"
fashion instead of needing to read a large block up-front.
2020-07-30 22:08:54 -07:00
ridiculousfish
81d5a3ea64 Do not add silent mode history items to history
Prior to this fix, if you invoked fish with --private and then used
`read --silent` to read something sensitive, the variable would be
stored in history, with the plain text available through up-arrow.
Fix it to not store items in silent mode.

Note the item was never written to disk; it was only stored in memory.

Fixes #7230
2020-07-30 20:26:01 -07:00
ridiculousfish
f7f35d2373 Fix a warning in fish_tests 2020-07-29 20:12:19 -07:00
ridiculousfish
2809d637db Introduce wwrite_to_fd
wwrite_to_fd() is a function which writes a wide string to a file
descriptor without performing any heap allocations.
2020-07-29 19:38:45 -07:00
ridiculousfish
a0cb23bea5 Introduce wcs2string_callback
This is like wcs2string, but instead of returning a std::string, it invokes
a user-supplied function with each converted character.

The idea is to allow interleaved conversion and output.
2020-07-29 19:36:20 -07:00
ridiculousfish
c9b42c6f1f Stop #include-ing wcstringutil.h in flog.h
This is a header dependency that we can break.
2020-07-29 17:04:18 -07:00