I recently upgraded the software on my macOS server and was dismayed to
see that cppcheck reported a huge number of format string errors due to
mismatches between the format string and its arguments from calls to
`assert()`. It turns out they are due to the macOS header using `%lu`
for the line number which is obviously wrong since it is using the C
preprocessor `__LINE__` symbol which evaluates to a signed int.
I also noticed that the macOS implementation writes to stdout, rather
than stderr. It also uses `printf()` which can be a problem on some
platforms if the stream is already in wide mode which is the normal case
for fish.
So implement our own `assert()` implementation. This also eliminates
double-negative warnings that we get from some of our calls to
`assert()` on some platforms by oclint.
Also reimplement the `DIE()` macro in terms of our internal
implementation.
Rewrite `assert(0 && msg)` statements to `DIE(msg)` for clarity and to
eliminate oclint warnings about constant expressions.
Fixes#3276, albeit not in the fashion I originally envisioned.
* Add completions for helm
helm - is a tool for managing Kubernetes charts. Charts are packages of
pre-configured Kubernetes resources.
See: https://github.com/kubernetes/helm
* Improve helm release completions description
After some feedback from the community it seems it is good to include
the chart in the release description. This adds the chart information to
the description. So to say this is `Release of CHART`.
* Further improvements to helm completions
- Utilize complete -f, -r and -x properly
- Add some more context aware completions (chart versions, kubectl context and namespaces)
I'm starting to wonder if IWYU is worth the effort. Nonetheless, this
makes it lint clean on macOS and reduces the number of warnings on
FreeBSD and Linux.
ncurses since 6.0 sends the "E3" sequence along with "clear", even for
just `clear` or `tput clear`. This deletes the scrollback buffer which
is usually not what you want.
Fixes#2855.
Some things like pyenv can change what `python` refers to, so what we
detect when we load the completions can become invalid later.
Also mentioned in #3840.
The issue here was that the `python` completion did a version check on
the `python` binary, so it would complete python2 stuff if system
python was py2, even if the user tried to complete `python3`.
This isn't beautiful, but it's more resilient than e.g. doing magic
with `commandline`.
Fixes#3840.
This puts a hard upper bound of 10 MiB on the amount of data that read
will consume. This is to avoid having the shell consume an unreasonable
amount of memory, possibly causing the system to enter a OOM condition,
if the user does something non-sensical.
Fixes#3712
* color: make brgrey really grey
The 0055 value is actually 0x2d which isn't 0x55 mentioned further and is probably a typo
* color.cpp: reformat color table
Tidy color table up and also fix hex number case for grey color. This should ease spotting errors like one from previous commit.
We now are stingier with taking history file locks - if the lock
is held too long we may just break it. But the current file save
architecture holds the lock for the duration of the save. It also
has some not-quite-right checks that can cause spurious failures in
the history stress test.
Reimplement the history save to retry. Rather than holding the lock,
rewrite the file to a temporary location and then take the lock. If
the history file has changed, start all over.
This is going to be slower under contention, but the advantage is that
the lock is only held for a brief period (stat + rename) rather than
across calls to write().
Some updated logic also fixes spurious failures that were easy to observe
when tsan was enabled. These failures were due to failing to check if the
file at the path was the same file we opened.
The next step is to move the history file saving to a background thread
to reduce the chances of it impacting user's typing.
Allow retrying, fix an issue where we trip over our own changes
by thinking the file has changed when we are responsible for changing
it, and improve some commenting
This class is used to accumulate data to be written to the history
file. It has some dubious optimizations around trying to track an
offset separately from the size of the buffer. After some investigation
these aren't helping, vector behaves fine on its own. So just make
this a simple wrapper around vector.
Before this change the function `__fish_print_filesystems` would print
an error message about an empty wildcard match for the pattern
`$PATH/mount.*`, if the current operating system does not include any
helper binaries for the command `mount`. An example for such an OS is
the current version of macOS (version 10.12).
Cache the escape sequences we've seen when checking for those which
don't take any visual space when writing the prompt or similar strings.
This reduces the cost of determining the true cost of such strings by a
full order of magnitude if they include lots of such escape sequences.
Periodically sort the cached escape sequence lengths based on feedback
from cache hits so that we're always checking for the most likely
sequence lengths first.
Also cache the prompt layouts to avoid doing the calculations if the
prompt doesn't change.
Fixes#3793
Change the escape key binding in insert mode (in vi key bindings)
to check if we are in paging mode. If so, emit cancel and stay in
insert mode. Otherwise perform the current behavior of switching
back to default mode and adjusting the cursor.
Fixes#2871
Currently, if bind is run with --mode but not --sets-mode, the
binding gets an implicit --sets-mode equivalent to the mode. This
is usually unobservable but it may matter if the mode is changed
by some internal part of the binding (e.g. set fish_bind_mode...)
then that setting will be lost after the binding is complete.