Comments (2)
Having slept on the idea I've decided there should be a $before-external-cmd
and $after-external-cmd
pair of callback lists.
In the before variant each callback in the list is called with a list composed of the full path to the command, the original command name, and all arguments. If it outputs $true
the next callback, if any, is invoked or the command is run. If it outputs $false
no remaining callbacks are run (including the "after" callbacks) and the external command is not run. The idea is that this allows a $before-external-cmd
callback to substitute different behavior for the external command. Possibly via emulation using only Elvish builtins or via some other external command (which itself is subject to the callbacks). Care needs to be taken to avoid infinite recursion. At a minimum a sane limit on callback recursion needs to be imposed by Elvish itself.
In the after variant each callback in the list is called with the time in fractional seconds the external command ran to completion, its numeric exit status, the full path to the command, the original command name, and all arguments. The after variant is primarily meant for logging which external commands are run but there may be other uses.
from elvish.
The callbacks should include additional info to make it easier to know the context in which the external command is being run; e.g., which module, script, or interactive context invoking the external command. This came to light in response to a change proposed by @xiaq to my PR #1680 to replace some external commands in the epm
module with builtins.
from elvish.
Related Issues (20)
- use edit breaks the edit namespace HOT 1
- Efficiently prepending to a list HOT 5
- Better integration with programs in other languages HOT 5
- Path completion works for var but not set
- Unicode hourglass is rendered with wrong char width HOT 4
- How to use `os.exists`? HOT 2
- `use` creates a namespace even when no module was loaded HOT 7
- Execute command line on Windows and dll in the same path HOT 2
- Support Shebang? HOT 3
- completion after wildcard character
- treat '#' as a bareword if it's after non-whitespace character HOT 3
- document interactive key bindings HOT 1
- document capturing multiline command output HOT 1
- New built function: filter HOT 4
- The digest of the windows installer is not stable HOT 2
- New built-in function: cons HOT 3
- Change the for loop to create a new binding per iteration HOT 1
- FYI: elvish has been added to WakeMeOps debian repo
- How to detect if the shell is interactive and login? HOT 19
- new rc location not being read HOT 4
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 elvish.