summaryrefslogtreecommitdiff
path: root/src/shell_manager.cc
AgeCommit message (Collapse)Author
2025-07-08Replace on_scope_end with CTAD with OnScopeEnd directlyMaxime Coste
2024-12-09Print elapsed time when blocked on opening file for writingJohannes Altmanninger
Extract the logic for "waiting for shell to finish" and reuse it for potentially blocking calls to open() that use the O_WRONLY flags.
2024-08-26Do not gather full input data in a single string when pipingMaxime Coste
Refactor ShellManager and pipe to feed lines from the buffer directly, this should reduce memory use when piping big chunks of buffers. The pipe output is still provided as a single big buffer.
2024-08-14Reduce number of included headersMaxime Coste
2024-08-12Move debug utils to debug.hh/debug.ccMaxime Coste
Lots of code includes buffer_utils.hh just for write_to_debug_buffer which pulls many unnecessary dependencies. Reorganise to reduce compile times.
2024-06-07Also check shell parameters for kak_* referencesMaxime Coste
This makes it easier to pass shell fragments as arguments so that %sh{ eval "$@" } just works even if arguments refer to Kakoune's vars.
2023-11-14Make shell-script-candidates completer run in the backgroundMaxime Coste
Read output from the script as it comes and update the candidate list progressively. Disable updating of the list when a completion has been explicitely selected.
2023-11-13Add missing include for std::arrayMaxime Coste
2023-11-13Rename stdin/stdout/stderr in Shell a they conflicts with macrosMaxime Coste
Fixes #5023
2023-11-05Refactor spawn_shell to return the relevant FDsMaxime Coste
This removes the need for the setup_child callback which is quite tricky as it cannot touch any memory due to vfork, and removes the Pipe abstraction in favor of a more general UniqueFd one.
2023-05-29Kill current shell on <c-g> during shell executionMaxime Coste
Closes #4907
2022-01-24Use strerror to display execve failuresMaxime Coste
Fixes #4501
2021-11-02Keep command_fifo read fd open instead of closing/reopeningMaxime Coste
Closing/reopening the read side seems to sometimes lead to end-of-file not being received, leaving some extra data unexecuted. The FDWatcher stays disabled during the executing of the fifo commands so this should not enable any more commands to be executed until we get back from the CommandManager and reset the FDWatcher fd to to fifo read end. Fixes #4410
2021-10-29Fix incorrect reading logic and EAGAIN handlingMaxime Coste
This is one of the issues raised by #4410
2021-10-24Fallback to basic path on platforms where _CS_PATH is not definedMaxime Coste
This happens on termux for example.
2021-08-10Avoid "env var" in error message for unknown %val expansionJohannes Altmanninger
This meaning is only used in C++ sources. The docs use "env var"/"environment variable" a few times for actual environment variables.
2021-07-07Catch errors while executing shell commandsMaxime Coste
Log error to debug buffer and Change the 'waiting for shell' face to 'Error'. Update the 'waiting for shell' message when the shell has exited but Kakoune is still waiting on stdin/stdout/stderr to be closed.
2021-07-07Add support for $kak_command_fifo and $kak_response_fifoMaxime Coste
Those fifos are accessible during %sh{...} blocks, the command fifo executes commands written to it once the write end side is closed (multiple open/write/close sequences are supported), the response fifo is a simple helper fifo available to write response back to the shell process An example use of this feature is to request some list options content from without being limited by the environment size: ``` %sh{ echo "echo -to-file $kak_response_fifo -quoting shell -- %opt{some_list}" > $kak_command_fifo eval "set -- $(cat $kak_response_fifo)" } ```
2021-07-07Decouple generate_env from actual ShellManager env var collectionMaxime Coste
2021-06-24Better styleSidharth Kshatriya
2021-06-24Also deal with variables named kak_quoted_* by using a more generic approachSidharth Kshatriya
2021-06-24Fix: Kakoune passed environment variables in shell invocations are repeatedSidharth Kshatriya
If a %sh{} script refers to any variables multiple times they are all multiply included in the environment. Example: if a %sh{} invocation refers to ${kak_buffile} 5 times, the environment will have "kak_buffile=..." repeated 5 times and so on. This repetition happens for each multiply used variable that is passed into the environment. The variable should, of course, be only passed into the environment once. This commit should fix this issue.
2021-03-11Do not select on non-urgent fd when handling only urgent eventsMaxime Coste
This avoids 100% CPU usage when we have pending fifo input while running a shell process, as we will not end-up busy looping in pselect but not reading the available data due to being only processing urgent events.
2021-03-04Refactor pipe reader/writerMaxime Coste
2021-01-22Write to stderr if execve failsMaxime Coste
This should be rare but should not happen silently, this way it will show in the parent process debug buffer.
2021-01-22Slight code cleanup in generate_envMaxime Coste
2020-12-09Add a libexec/ directory and use it to find the kak commandMaxime Coste
Add that libexec directory to the PATH instead of the current kak binary directory to avoid impacting other commands. The libexec directory currently only contains a symlink back to the Kakoune binary.
2020-03-02Expand env vars as list of stringsMaxime Coste
This makes it possible to do :select `%val{selections_decs}` and to correctly combine $kak_quoted with those.
2019-06-23Make quoting opt-in by using $kak_quoted_...Maxime Coste
2019-01-24Fix missing errno includeMaxime Coste
2019-01-20Refactor RegexIterator to use a SentinelMaxime Coste
2018-12-27Use fork instead of vfork on CYGWINMaxime Coste
Fixes #2653
2018-12-07Use _exit() after vfork()Jason Felice
Closes #2620 The docs for Mac OS X's vfork() requires it, and _exit() conforms to POSIX.1-2008. http://man7.org/linux/man-pages/man2/_exit.2.html
2018-12-06Use a dummy function for SIGPIPE instead of SIG_IGNMaxime Coste
SIG_IGN is inherited after 'execve' and requires us to reset that signal handler, which does not work well with vfork on OSX. Using an empty function does the trick and will be auto reset to default on exec.
2018-11-27Support KAKOUNE_POSIX_SHELL environment variable to choose the shell pathMaxime Coste
The shell will always be run with 'sh' as argv[0] to make shells such as busybox sh supported. Closes #2547
2018-11-27ShellManager: Use vfork instead of forkMaxime Coste
When large buffers have been opened, copying Kakoune's memory page descriptors can get pretty slow, making fork more expensive than necessary. vfork avoids that problem. While not strictly conforming, it seems the few calls we do before execve (open, close, dup2 and set_signal_handler) would not cause any problems on platforms we care about.
2018-08-29Use shell specific quoting for env varsMaxime Coste
Add a test case to validate roundtrips between Kakoune and the shell.
2018-07-23Restore SIGPIPE handler to default before spawning shellMaxime Coste
Fixes #2238
2018-06-28Fix wrong logic for moving filedescriptors leading to closed stdinMaxime Coste
With this fix, tests can now use /dev/null as stdin. Fixes #2165
2018-05-26Do not expose C++ typeid().name to user facing errors on wrong option typeMaxime Coste
Fixes #2079
2018-04-07Make FaceRegistry scopedMaxime Coste
set-face now takes a scope argument, and faces can be overridden on a buffer or window basis. colorscheme apply on global scope, which should be good enough for now. Fixes #1411
2018-04-01Restore previous status line after notifying wait for shellMaxime Coste
Fixes prompt getting erased by the wait for shell message, and having to manually trigger a redraw to see it again.
2018-03-30Support full redraws during shell execution and handle resize thereMaxime Coste
Fixes #1973
2018-03-25Remove contains_that and use any_of to be closer to the c++ stdlibMaxime Coste
2018-03-13ranges: Add transform overload taking directly a pointer to memberMaxime Coste
This overload will forward to the general transform implementation using std::mem_fn to generate a callable.
2018-02-18ShellManager: init from a static list of env varsMaxime Coste
No need to go through a static list and then copy them one by one in a vector.
2018-01-11Remove extraneous face when clearing status lineDelapouite
2017-06-07Use microseconds instead of milliseconds for built-in profilingMaxime Coste
2017-06-07Use range based find_if wrapper for finding shell env varsMaxime Coste
2017-04-22Set stdin to /dev/null instead of closing it when we dont have data to pipe ↵Maxime Coste
to child Fixes #1330 Fixes #1331