Giter Club home page Giter Club logo

Comments (2)

krader1961 avatar krader1961 commented on May 26, 2024

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.

krader1961 avatar krader1961 commented on May 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.