The fish_key_reader program was the only user of the
`set_wait_on_escape_ms()` function and that use was removed with commit
0461743. So remove it from the main fish code. This was found by `make
lint`.
Update the CHANGELOG to more accurately reflect what will be included in
the 2.4.0 release vis-a-vis the `history` command behavior.
I noticed that the compiler was emitting some harmless warnings related
to the history changes so deal with those as well.
This modifies the code path for `set PATH` and `set CDPATH` to emit an
easier to understand warning when an entry in those vars is invalid. For
example
$ set PATH $PATH /tmp/arglebargle
set: Warning: $PATH entry "/tmp/arglebargle": No such file or directory
$ mkdir /tmp/d
$ chmod 0 /tmp/d
$ set PATH $PATH /tmp/d
set: Warning: $PATH entry "/tmp/d": Permission denied
$ touch /tmp/x
$ set PATH $PATH /tmp/x
set: Warning: $PATH entry "/tmp/x": Not a directory
Fixes#3450
* Fix building on Android by avoiding getpwent() if missing with autoconf check
The getpwent() function does not link when building for Android,
and user names on that platform are not interesting anyway.
Using a configure check for stat.st_ctime_nsec fixes building on
Android which has that field but does not define STAT_HAVE_NSEC.
Before this change the Android build failed on the st_ctim.tv_nsec
fallback #else clause.
Taking a different approach here. I can't see why we'd only want to
recognize certain colors. Now, we'll just try all the colors fish might
use.
This could probably be optimized now that there are more
than 8 (or 16) colors fish can do.
It is believed there are no longer any platforms we support that do not
support passing NULL as the second argument to realpath(). So rather
than duplicating the logic to get reasonable behavior from our
wrealpath() wrapper simply remove the redundant implementation.
After implementing `builtin fish_realpath` it was noticed that it did
not behave like GNU `realpath` without options. Which is super annoying
since that was the whole point of implementing the command. Major
failure on my part since I wrote the unit tests to match the behavior of
the existing `wrealpath()` function that I simply exposed as a builtin
command. Rather than actually verifying it behaved in a manner
compatible with GNU realpath.
Also, while the decision to call the builtin `fish_realpath` seemed to
make sense at the time of the original commit further reflection has
shown that to be a silly, idiosyncratic, thing to have done. So rename
it to simply `realpath`.
Fixes 3400
It's the ninth color - on virtual consoles this was likely to
try a color that doesn't work because we checked if max_colors >= 8.
Add another way to reach that color on terminals with only 8 colors
by using bold mode to get a bright.
This has potential to fail by simply rendering as black which can cause
it to be invisible on a white-on-black terminal. Not bad as it's just
making this bell/whistle invisible:
We *really* want to set the omitted newline character apart by having
it appear grey. On (FreeBSD consoles, at least) VCs it's not uncommon
for it to render as a "?". It's particularly confusing if it doesn't
render in a darker color as it cannot be discerned from actual program
output.
When performing fuzzy completion, if a directory segment is
valid, then don't consider it for a fuzzy match even if
the literal match produces no results.
Fixes#3211
The use of wcstoimax causes certain out-of-range values
to be silently truncated (e.g. when converted to a pid),
and is incompatible with FreeBSD (see #626)
This reverts commit 6faa2f9866.
The template has different behavior around interpreting
non-decimal sequences. This doesn't seem to have been intended.
This reverts commit f843eb3d31.
Both GNU and BSD have bugs regarding the classification of
non-characters and private use area characters. Provide wrappers around
iswalnum(), iswalpha(), and isgraph() to provide a consistent
experience. We don't bother to autoconf the use of these wrappers for
several reasons. Including the fact that a binary built for one distro
release should behave correctly on another release (e.g., FreeBSD 10
does the right thing while FreeBSD 11 and 12 do not with respect to
iswalnum() of code points in the range 0xFDD0..0xFDFF).
Also move a few functions from common.* to wutil.* because they are wide
char specific and really belong in the latter module.
Fixes#3050
* Adds a template to parse integers easily.
It's not enough to use intmax_t and check for empty strings: there are
limits. Adds a template to make it easy to parse an integer of any type.
Adds a compiler flag to flag existing dangers.
* nix warning, include <limits>, fix namespace error.
on MacOS `xcodebuild -quiet` will flag these intmax_t -> * conversions,
just use that if you want to find them.
This adds a flag to the `history search` command to limit the number of
matching entries to the first "n". The default is unlimited. This is
mostly useful in conjunction with aliases (i.e., functions) that are
intended to report the "n" most recent matching history entries without
piping the result through the user's pager.
Fixes#3244
If one does a make fish; ./fish - don't use the make-installed paths.
Also, remove huge chunk of nearly duplicated code #ifdef'd __APPLE__
for relocatable dirs in fish.app: the directories under Resources
in the bundle followed by the changes I made around here a few months
ago now are not different enough that they require a special case.
This works fine for fish.app.
I was surprised fish_indent was running from /usr/local/bin
instead of the git checkout when I ran ./fish
after building fish there. This was more easily noticable after my last
commit. I added some debug lines which probably fish could have been
doing already when looking into that.
This is a pretty major thing during fish initialization, commit it for
everyone.
This deprecates the use of long options for history sub-commands (e.g.,
`history --delete`) in favor of proper sub-commands (e.g., `history
delete`). It also eliminates the short options for those sub-commands.
Also change option processing to allow options anywhere on the command
line to match how the vast majority of fish builtins handle flags.
Replace --with-time with --show-time.
Fixes#3367
Adds a color reset thing, to ensure fish tries to use hard colors during
testing.
Also, work on a discrepancy (not introduced by my changes, afaik) when
with some combinations of color settings, and usage of --bold, caused super
flakey color paninting in the pager. Downwards movements that trigger
scrolling vs. upwards movement in the pager would only apply bold to
selections when moving upwards. The bold state of the command completions in
the pager was flipping flops on and off, depending on if there is a description
on the preceding line.
Implement a lame fix by reseting the color to normal and applying a
different style on the rightmost ')' which seems to be what was influencing it.
Makes fish use terminfo for coloring the newline glich char.
Fixes various spots throughout fish where broken strtoi checks
were converting empty strings to zero. Zero is not a valid pid and
this was causing breakage as well when input.
Nix fish_wcstoi - wcstoimax does the same thing.
Improve comments and some general cleanup.
If an interactive job is started, and it is reaped within fish's
exit handler, we may attempt to print its status message after
cur_term has been set to NULL. This results in a crash.
This change makes fish only print the status message if cur_term is
not NULL.
Fixes#3222
Update history docs.
Note - the omission of a mention of timezone was intentional. These were recorded as naive timestamps lacking timezone information in the first place.
Improves the grouping of multiline history entries
by sepearating the timestamps and history entires onto seperate lines.
Use wcsftime() Saves us a conversion, might as well.
Implementing the --shadow-builtin flag has proven to be highly controversial.
Revert the introduction of that flag to the `function` command. If someone
shoots themselves in the foot by redefining a builtin as a function that's
their problem and not our responsibility to protect them from doing so.
Fixes#3319
In the C/POSIX locale EOF on the tty wasn't handled correctly due to a change
a few months ago to fix an unrelated problem with that locale. What is
surprising is that the core fish code doesn't explicitly depend on
input_common_readch returning WEOF if a character isn't seen within
`wait_on_escape_ms` after an escape.
Fixes#3214
The `fish_key_reader` program emits an example `bind` command for the sequence
of keystrokes it sees. However, if that sequence includes a space or del
character the example `bind` command includes extraneous commentary that makes
the command invalid.
Fixes#3262
The recent change to reconcile the history builtin command and function
broke an undocumented behavior of `history --delete`. This change
reinstates that behavior. It also adds an explicit `--exact` search mode
for the `--search` and `--delete` subcommands.
Fixes#3270
Commit acfd3801 included a legitimate bug fix and a second change that
didn't correct an actual bug but made the code more fragile. Revert the
second part of that commit (while also suppressing the uninitialized
variable compiler warning that caused the ill-advised change).
Just use static_cast directly instead of inscrutible "shortcut"
macro.
It was not always used and doesn't seem to do much besides scramble
things up; encountering CAST_INIT() in the code seems likely to lead
to head scratching due to the transformation taking place.
It was added to save folks typing the type twice, now with 100
columns available, let's roll that convenience macro back.
sockaddr_dl:
Perform reinterpret_cast<sockaddr_dl> conversion. The cast affected
alignment and looks fishy to a compiler (but it's fine). Ditch
C-style cast and communicate we're doing that on purpose.
Where we already manage to cover an enum entirely in a switch
statement such that default: cannot be reached, help ensure
it stays that way by condemning that route.
Also adjust a 'const' I came across that is ignored.
A user reported that fish was dying from a SIGSEGV when launched by the
sjterm terminal app. This was traced to a bug in sjterm passing an empty
argv array to the shell. Which, while technically legal, is very unusual
and a bad practice.
Fixes#3269
Fish assumed that it could use tparm to emit escapes to set colors
as long as the color was under 16 or max_colors from terminfo was 256::
if (idx < 16 || term256_support_is_native()) {
// Use tparm to emit color escape
writembs(tparm(todo, idx);
If a terminal has max_colors = 8, here is what happenened, except
inside fish:
> env TERM=xterm tput setaf 7 | xxd
00000000: 1b5b 3337 6d .[37m
> env TERM=xterm tput setaf 9 | xxd
00000000: 1b5b 3338 6d .[39m
The first escape is good, that second escape is not valid.
Bright colors should start at \e[90m:
> env TERM=xterm-16color tput setaf 9 | xxd
00000000: 1b5b 3931 6d .[91m
This is what caused "white" not to work in #3176 in Terminal.app, and
obviously isn't good for real low-color terminals either.
So we replace the term256_support_is_native(), which just checked if
max_colors is 256 or not, with a function that takes an argument and
checks terminfo for that to see if tparm can handle it. We only use this
test, because otherwise, tparm should be expected to output garbage:
/// Returns true if we think tparm can handle outputting a color index
static bool term_supports_color_natively(unsigned int c) { return max_colors >= c; }
...
if (term_supports_color_natively(idx) {
And if terminfo can't do it, the "forced" escapes no longer use the fancy
format when handling colors under 16, as this is not going to be compatible with
low color terminals. The code before used:
else {
char buff[16] = "";
snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx);
I added an intermediate format for colors 0-15:
else {
// We are attempting to bypass the term here. Generate the ANSI escape sequence ourself.
char buff[16] = "";
if (idx < 16) {
snprintf(buff, sizeof buff, "\x1b[%dm", ((idx > 7) ? 82 : 30) + idx + !is_fg * 10);
} else {
snprintf(buff, sizeof buff, "\x1b[%d;5;%dm", is_fg ? 38 : 48, idx);
}
Restores harmony to white, brwhite, brblack, black color names.
We don't want "white" to refer to color color #16, but to the
standard color #8. #16 is "brwhite".
Move comments from output.h to output.cpp
Nuke the config.fish set_color hack for linux VTs.
Sync up our various incomplete color lists and fix all color values.
Colors 0-8 are assumed to be brights - e.g. red was FF0000. Perplexing!
Using this table:
<http://www.calmar.ws/vim/256-xterm-24bit-rgb-color-chart.html>
Fixes#3176
Add some debug output like there is for 24bit mode.
I see now there is no need to setup terminal here - we get called early
sometimes for colors to work in config.fish to work but that is not so fatal.
Just check cur_term and trust get called again soon.
This fixes several problems with how the builtin `history` command handles
arguments. It now complains and refuses to do anything if the user specifies
incompatible actions (e.g., `--search` and `--clear`). It also fixes a
regression introduced by previous changes with regard to invocations that
don't explicitly specify `--search` or a search term.
Enhances the history man page to clarify the behavior of various options.
This change is already far larger than I like so unit tests will be added
in a separate commit.
Fixes#3224.
Note: This fixes only a couple problems with the interactive `history
--delete` command in the `history` function. The main problem will be
dealt with via issue #31.
We were effectively inferring 256 color support **only**.
If terminfo reports 256 max_colors for this $TERM but
that is not named xterm or does not contain "256color" in name,
term256_support_is_native()'s result did not affect the recorded
support.
Noticed with Terminal.app set to nsterm, and a newer ncurses
with good terminfo for the terminal on modern OS X:
http://invisible-island.net/ncurses/terminfo.src.html#toc-_Apple__Terminal_app
We don't seem to mention in the documentation that we were forcing
-t for all interactive uses. If we want to do that we should apply
that in the builtin.
history.fish reimplementing every option and doing things kind of
differently is a real pain and it's not clear if the docs are
referring to the or the wrapper script or both.
Attempting to execute something like `exec "$test"` results in a fish internal
token (a Unicode private use char) being printed in the resulting error
message. That's obviously not desirable as well as confusing.
Fixes#3187
Prior to this fix, when performing completions, we would prepend
the wildcard to the resulting files. When doing fuzzy completions,
we would take some wildcard segment, attempt to locate it in the
final completion, and then replace it with our fuzzy-matched directory.
With this fix, we pass along the "resolved so far" path, and prepend
that instead of doing "surgery" on the completion. This simplifies the
logic.
Fixes#3185
Someone running fish in an unusual locale reported that an `assert()` was
firing when they typed `pkill c`. I traced it to two bugs. First, the
__fish_make_completion_signals command was producing a weird result. Second,
the builtin `complete` command wasn't adequately verifying its arguments.
Fixes#3129
Make `fish_indent`, `fish_key_reader` and `fish` recognize and assign
the same meaning to the `-d` and `-D` flags. Also, fix some errors and
stylistic issues in the associated man pages.
Fixes#3191
Remove isatty() check for stdout - this was added for both stdout
and stdin because "there is no reason to do that", but there is one:
Leaves only the bind command printed ot stdout, this allows
for one to do `fish_key_reader > bind_command.fish` to capture the bind
command while seeing the rest of the output.
After the colorized syntax output in type -a foo, "foo is /usr/..."
would also be colored. (or 'test' in fish_indent foo.fish; echo test).
Make fish_indent reset the color when it's done.
I did some research and experiments. For good or bad the `bind` command
requires the use of wide char codepoints (e.g., \u1234) for non-ASCII
chars. So don't force the use of the POSIX locale, but do provide it as
an option for people who want to see the individual bytes rather than a
decoded wide char.
Simplify the format of the information displayed for each character. There
really isn't much point in providing decimal, octal, and hexadecimal. Just
print hex and symbolic representations.
Add an example `bind` command that a user can copy/paste.
Closes#3183
Another developer noticed that redirecting stdin of `fish_key_reader`
results in weird behavior. Which is not at all surprising. So add checks
to ensure stdin and stdout are attached to a tty.
Add some rudimentary unit tests for this program.
A discussion on Gitter proposed allowing the user to signal their desire to
exit fish_key_reader by pressing \cC or \cD twice in a row. This implements
that.
I also decided to refactor how signals are handled. Most notably receiving a
signal will no longer print a diagnostic message unless you've enabled
debugging with `-d2` (or higher level).
In addition to fixing the setting of the locale to C/POSIX this also
corrects several problems introduced by the commits made in the past
couple of days. As a consequence of dealing with all of this I decided
to refactor the code to simplify one of the overly long functions I
introduced in my previous change.
Fixes#3168
There is no conceivable way in which timef()'s invocation of gettimeofday()
can fail where it makes sense to continue running. Yes, one such,
legitimate, failure mode is a 32-bit kernel and the date is greater than
2038-01-19 03:14:07. If you're running a fish binary on such a system
it's time to upgrade. Otherwise, either the hardware or OS is broken.
Fixes#3167.
* Correct notice about ^C
* Move time deltas to end of the line away from the important info on
left.
* Use timef() instead of gettimteofday() ourselves
* Show time in ms (is this even useful in any unit? Maybe testing escape
delays...)
* Make init more similar to other apps.
```
~ $ set -e TERM; fish
Assertion failed: (!is_missing), function c_str, file src/env.cpp, line 690.
fish: 'fish' terminated by signal SIGABRT (Abort)
```
The tty device timestamps on MS Windows aren't usable because they're always
the current time. So fish can't use them to decide if the entire prompt needs
to be repainted.
Fixes#2859
* if (result == ULLONG_MAX) is always false, likely a typo as
result is unsigned long, and the comment says ULONG_MAX.
* use off_t instead of size_t for file size where it can mismatch
st_size's type in stat.h
For example, an argument 12345^ is a real argument, not a redirection
There's no reason to use ^ here instead of >, and it's annoying to git
users.
Fixes#1873
When given no path, the logic was happy to try to use
an unitialized output_location.
$ fish_indent -w < test.fish
Opening "(null)" failed: Bad address
Initialize the string, and repair the logic to catch this case
and report the problem correctly.
Update Xcode project, HeaderDoc comments.
Fix various invalid HeaderDoc comments. Normalize autoload.cpp/autoload.h as an example of something closer to "proper" HeaderDoc formatting.
Have clang/Xcode validate HeaderDoc comments. Remove key_reader.cpp from Xcode project.