Comments (5)
The use case for which lucid prompt uses block is to ensure no "process exit" events are processed until the corresponding --on-process-exit handler is set up.
This hasn't been necessary since #7210 and 6d00ad1
from fish-shell.
It blocks all events - --on-event
is merely what we internally call a "generic" event, the others are also events.
block
is, at the moment, essentially unusable and we're most likely going to remove it. See #9030.
from fish-shell.
Thanks @faho, please bear with me some more :)
The use case for which lucid prompt uses block
is to ensure no "process exit" events are processed until the corresponding --on-process-exit
handler is set up.
In code (this is of course made-up to illustrate the point in a terser way than by referencing the lucid code):
begin
block -l
sh -c 'echo "doing some work in the background..."' &
sleep 1 # enough time to ensure the background job completes
set -l pid $last_pid
function __on_pid_{$pid}_exit --on-process-exit $pid
echo "the background work has been done"
functions -e (status function) # cleanup
end
end
In my tests, the code above seems to run "well" regardless of whether the initial block -l
line is included or commended out.
I assume that must (?) be because there is only one thread that runs the begin..end
block and the __on_pid_x_exit
function and, moreover, that thread determines which --on-process-exit
to run by some kind of polling rather the handler functions being identified asynchronously when SIGCHLD is received.
Now, unless the above behavior is "set in stone" so that one can rely on it (but I can't find it documented anywhere?) and not just how the current C++ implementation turned out to behave, I believe removing block
would leave no general solution for this use case.
Does this seem to make sense?
from fish-shell.
BTW:
hydro works around the problem by using universal variables as events (ie. the background job sets an universal variable when it's done, and the parent shell reacts via an --on-variable
function it had previously registered), but that has two drawbacks:
- it requires the background job to be a fish instance (and not one started with
--no-config
, which makes startup considerably slower) - it only works as long as one can guarantee there is only one such background job running at the same time
from fish-shell.
That's great then :)
I'll add a TODO to clarify the documentation in my personal TODO list (no promises though)
from fish-shell.
Related Issues (20)
- Trying to generate a fun string when I start a new fish shell session (new tab, or source)--not quite working HOT 2
- [ feature request ] Compile fish scripts to wasm HOT 1
- Slow to startup on fresh boot of macOS HOT 8
- Unnecessary capitalization / completion for command `scp` HOT 1
- curl file completion doesn't work for @ HOT 3
- export function not expanding tilde HOT 1
- Documentation: `export` works fine HOT 3
- [Feature] Allow non-127 returns from fish_command_not_found HOT 1
- How to sync history only when ctrl+r shotcut press?
- Build fails without a C++ compiler HOT 1
- No documentation for "internally generated named events" HOT 2
- disown key binding to fzf with xargs HOT 2
- detect shell is fish in executable for auto-complete HOT 2
- Shell Input Redirect Fails HOT 5
- Weird error whenever I open terminal HOT 3
- large memory usage when run large lines code HOT 1
- Crash on vim mode: `/src/input.cpp:367: failed assertion: event_storage_.empty() && "event_storage_ should be empty"` HOT 6
- UX: History pager changes number of columns while typing
- fish: Unknown command: __history_previous_command_arguments HOT 1
- Pasting long text makes the terminal go completely blank. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fish-shell.