Commit Graph

3375 Commits

Author SHA1 Message Date
ridiculousfish
994f95b845 Move inputter_t private bits to the bottom of the class
Just a reorganization to clarify what parts are the interface.
2020-11-23 19:36:39 -08:00
ridiculousfish
050a211838 Clarify the role of the 'in' param in inputter_t constructor 2020-11-23 19:36:39 -08:00
ridiculousfish
48c50d202b Save a string allocation in expand_arguments_from_nodes
This function is called a lot; we can save a little bit of memory here.
2020-11-23 19:36:39 -08:00
Fabian Homborg
2e55e34544 Reformat 2020-11-22 14:39:48 +01:00
Mahmoud Al-Qudsi
3699e50e00 Explicitly check for KERN_PROC_PATHNAME
While FreeBSD, DragonflyBSD, and NetBSD have KERN_PROC_PATHNAME,
OpenBSD does not.
2020-11-20 15:49:57 -06:00
Mahmoud Al-Qudsi
be78e9dc28 fixup! Unify handling of BSD systems where applicable 2020-11-20 15:06:19 -06:00
Mahmoud Al-Qudsi
06f1b34553 Correct reporting of setpgid (parent vs child)
Previously, it always said "own process" (e.g. child error).
2020-11-20 14:22:42 -06:00
Mahmoud Al-Qudsi
e4c052330f Handle ESRCH from setpgid(2) on FreeBSD 2020-11-20 14:18:02 -06:00
Mahmoud Al-Qudsi
76faee71a5 Unify handling of BSD systems where applicable 2020-11-20 14:11:03 -06:00
Fabian Homborg
3c14d310a0 reader: Stop converting to wchar and back to wcstring
This called completion_insert with a wchar_t*, which was then passed
to a function that takes a wcstring.
2020-11-15 15:27:19 +01:00
Fabian Homborg
263ef55ae6 reader: Use erase directly
No need to use a separate reference.

Also no need to erase from begin(), just use the indices.
2020-11-15 15:26:52 +01:00
Fabian Homborg
3eba6c5d5a signal: Remove redundant set 2020-11-15 15:20:55 +01:00
Fabian Homborg
c23fc9a365 builtin_test: Exit early on float parsing error
cppcheck complains about a possible null-dereference.
2020-11-15 15:15:20 +01:00
Fabian Homborg
a8f259f685 Remove unused debug_escape function 2020-11-15 15:15:10 +01:00
Fabian Homborg
9c2d22e452 Remove debug_stack_frames
This was unused with FLOG. We leave the option stubbed out for now, so
we don't error out for well-meaning calls.
2020-11-15 11:32:52 +01:00
Fabian Homborg
95e86cf2d2 Remove the old debug macro and impl
This should make calling `debug()` impossible. Some of the other
bits remain, to be removed later.
2020-11-15 11:28:01 +01:00
Fabian Homborg
b32540f346 proc: Remove unused function 2020-11-15 11:26:45 +01:00
Fabian Homborg
01cd6385ff reader: Make param const
const good! Fabian like const!
2020-11-15 11:26:15 +01:00
Fabian Homborg
9f924f37fb reader: Pre-increment
If we don't do it now, static analysis things are just gonna bug us
until someone does it.
2020-11-15 11:25:45 +01:00
Fabian Homborg
575d574691 ast: Remove unused variable 2020-11-15 11:19:23 +01:00
Érico Rolim
21041e3cc7 src: don't split wide char strings that are used with gettext.
A bug in xgettext leads to the generation of useless msgids in the po
files for these strings.
2020-11-13 14:34:42 +01:00
Érico Rolim
6e9d5c00e5 src/builtin_type.cpp: add missing gettext call.
The string "%ls is %ls", which is printed when `type <command>` is ran
for a command in PATH, couldn't be localized, since it was missing _()
around it.
2020-11-13 14:31:40 +01:00
ridiculousfish
17fc542082 Revert "Stop caching line breaks in the prompt calculation"
This reverts commit a2ff32d904.

Per comments on the commit, the original code had correct handling of line
breaks inside escapes.
2020-11-12 10:55:11 -08:00
Fabian Homborg
5ee3eeff5d Remove the final two debug() calls 2020-11-07 10:20:52 +01:00
Mahmoud Al-Qudsi
640f4444f5 Disable SIGIO notifier on WSL
It currently does not trigger the uvar notifier and fails the automated
tests.

See #7429.
2020-11-06 20:49:44 -06:00
Fabian Homborg
65c5433662 Delete unused field
Fixes #7456.

[ci skip]
2020-11-06 17:44:09 +01:00
ridiculousfish
d3192d37a2 Allow timing-out I/O-able syntax highlighting after expanding abbreviation
It may happen that the user types an abbreviation and then hits return.
Prior to this commit, we would perform a form of syntax highlighting
that does not require I/O, so as to not block the user. However this
could cause invalid commands to be colored as valid.

More generally if the user has e.g a slow NFS mount, then syntax
highlighting may lag behind the user's typing, and be incorrect at the
time the user hits return. This is an unavoidable race, since proper
syntax highlighting may take arbitrarily long.

Introduce a new function `finish_highlighting_before_exec`, which waits
for any outstanding syntax highlighting to complete, BUT has a timeout
(250 milliseconds). After this, it falls back to the no-I/O variant, which
colors all commands as valid and nothing as paths.

Fixes #7418
Fixes #5912
2020-11-05 20:07:05 -08:00
ridiculousfish
c861fdadcf Remove return value from iothread_perform
It was not actually used by any test.
2020-11-05 19:28:26 -08:00
ridiculousfish
a2ff32d904 Stop caching line breaks in the prompt calculation
These are fast enough to find on demand.
2020-11-01 14:45:35 -08:00
Soumya
80aaae5b74 Clear to end of each line in left prompt 2020-11-01 13:29:26 -08:00
Fabian Homborg
2a07673561 Don't call a variable "stdin"
Musl has a macro that interferes.
2020-10-31 18:15:19 +01:00
Fabian Homborg
0951a706cf Let read read from fds other than 0
This allows

read </dev/tty

to work.

Fixes #7358
2020-10-31 13:39:20 +01:00
Fabian Homborg
d334dc6643 Let cancel after an unambiguous completion was accepted undo it
In some cases the completion we come up with may be unexpected, e.g.
if you have files like

/etc/realfile

and

/etc/wrongfile

and enter "/etc/gile", it will accept "wrongfile" because "g" and
"ile" are in there - it's a substring insertion match.

The underlying cause was a typo, so it should be easy to go back.

So we do a bit of magic and let "cancel" undo, but only right after a
completion was accepted via complete or complete-and-search.

That means that just reflexively pressing escape would, by default, get you back to
the old token and let you fix your mistake.

We don't do this when the completion was accepted via the pager,
because 1. there's more of a chance to see the problem there and 2.
it's harder to redo in that case.

Fixes #7433.
2020-10-30 19:37:44 +01:00
Johannes Altmanninger
5ff2d38d4c builtin time: print help on invalid syntax
I always mix up the order with variable assignments.
2020-10-26 19:25:41 +01:00
Fabian Homborg
a84d57b02b math: Actually report closing paren error
This was typically overridden by "too many/few arguments", but it's
actually incorrect:

    sin(55

has the correct number of arguments to `sin`, but it's lacking
the closing `)`.
2020-10-26 18:13:43 +01:00
Rosen Penev
cef84cf2c2 clang-tidy: use append
Found with performance-inefficient-string-concatenation

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-10-25 22:54:51 -07:00
Rosen Penev
334be56021 run codebase through clang-tidy
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-10-25 22:48:49 -07:00
Mahmoud Al-Qudsi
332287708b Prevent fish from re-importing an exported fish_user_paths
fish_user_paths is a fish-specific variable that can be persisted by
making it a universal variable or by making it a global variable set at
startup in `config.fish`.

Since it is not defined in a clean installation, a user could
inadvertently create it as `set -Ux fish_user_paths ....` the first
time, creating a horrible, ugly, self-loathing mess that will have you
chasing ghosts and bisecting for naught once fish re-imports
fish_user_paths as a *global* variable that shadows the universal one.

While that is true for any universal variable that is re-imported as a
global variable, only fish_user_paths has the potential to really screw
things up because we also re-export PATH based off of its value in turn.
2020-10-25 21:45:45 -05:00
ridiculousfish
a34b9036ba Enable SIGIO notifier on FreeBSD
Now that SIGIO works on FreeBSD, switch to that uvar notifier
2020-10-25 14:53:56 -07:00
ridiculousfish
e669c41d1b Fix up SIGIO notifier tests
FreeBSD has the behavior where SIGIO is delivered on a read. Teach the
tests how to handle this behavior.
2020-10-25 14:53:31 -07:00
ridiculousfish
8bb20a8d91 Remove use of POLL_IN in SIGIO uvar notifier
This fixes up the SIGIO notifier in preparation for using it on BSD. It
removes the reliance on the signal's si_code, which is not available in
BSD, and it properly handles the BSD behavior where SIGIO is delivered on
a read even if the read returns EAGAIN.
2020-10-25 14:52:37 -07:00
Mahmoud Al-Qudsi
3652bcf731 fixup! Fix assertion failure on job redirection error 2020-10-24 17:59:11 -05:00
Mahmoud Al-Qudsi
64671c64a1 Fix assertion failure on job redirection error
Fix an error caused by `exec_job()` assuming a job launched with the
intention of being backgrounded would have a pgid assigned in all cases,
without considering the status of `exec_error` which could have resulted
in the job failing before it was launched into its own process group.

Fixes (but doesn't close) #7423 - that can be closed if this assertion
failure doesn't happen in any released fish versions.
2020-10-24 16:15:40 -05:00
ridiculousfish
bbbbe00c81 Handle being launched with control of the tty, but not in own pgroup
It is apparently possible to launch fish such that its pid owns the tty,
but its pid is in a different pgroup. In that case, do not attempt to stop
with SIGTTIN; instead simply attempt to place fish in its own pgroup.

Fixes #7388
2020-10-18 14:37:31 -07:00
Fabian Homborg
5abc6060a4 Disable sigio notifier on FreeBSD
This fails for unknown reasons.

Not looking like a great *replacement* for the named pipe now, tbh.

See #7400.
2020-10-14 20:40:15 +02:00
Collin Styles
da0acb28ba Don't chomp foo= when completing foo=br
`complete_param_expand` knows how to handle cases like `foo=br` so we
don't need to bother sending just the `br` part. Furthermore, sending
just `br` is incorrect because we will end up replacing the entirety of
`foo=br` with the result of the completion. That is, `foo=br` will be
replaced with `bar` instead of being completed to `foo=bar`.
2020-10-14 18:35:54 +02:00
Johannes Altmanninger
ddf0a8e461 Refactor: slightly rework how variables are assigned during completion
Seems better since we now have two callers. This would be a good use case for
[[nodiscard]].
2020-10-10 13:00:47 +02:00
Johannes Altmanninger
8ef8fb3d94 Refactor: omit parens in lambdas with no parameters
TIL []{} is a thing.  We already do that in some places, so this improves
consistency, although it may be less obvious.
2020-10-10 13:00:24 +02:00
Johannes Altmanninger
c325603d73 Honor variable assignments on the commandline when completing files
This had already worked before although the implementation used to be rather
crude and was cleaned up in
e88eb508d0 (r42759188)
2020-10-10 12:59:55 +02:00
Johannes Altmanninger
eca2a8ba55 complete: print completions without the implied -c switch
This switch is no longer necessary when only one command is given.
Internally completions are stored separately for each command,
so we only every print one command name per "complete" line anyway.
2020-10-10 11:54:52 +02:00