Skip to content

Should %run be the built-in way binaries are run? #80

@jpco

Description

@jpco

es has a hook function called %run for fork/exec-ing a binary with the given arguments as its argv. This is cool, but the function isn't actually used by es itself without some hackery to %pathsearch

fn %pathsearch name {
  result %run <={access -n $prog -1e -xf $path} $prog
}

and then potentially doing something to deal with the fact that %whatis bin now returns the ugly

%run /path/to/bin bin

and then feeling sad about the fact that if a user passes in an absolute path, %run just won't be called.

It seems more es-ish to just replace the forkexec() calls in eval() with calls to %run (or maybe fall back to $&run, if %run isn't set). Outside of $&run, eval() is the only place where forkexec() gets called, so having eval() go through $&run would make it the only way binaries are invoked.

A concrete possibility this enables is the setting of a bash- or zsh-like $_ for any invoked binary (from man bash, this: "the full pathname used to invoke each command executed and placed in the environment exported to that command"), like this:

let (r = $fn-%run)
fn %run cmd args {
  local (_ = $cmd) $r $cmd $args
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions