-
Hello all, I have a new use-case and I'd like feedback on the way I attempted to tackle it. I've been using the Windows WSL feature on a work machine, and I installed es there as my user shell. One of the things I miss in this environment is being able to type a command In any case, I've successfully overridden
And although My question is, which function should I edit to set up a custom command name resolution working? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
The quick answer:
There's a little nuance with this that you might want to figure out for yourself. For example, if you have a More in-depth technical discussion follows. In es, every command is one of three things:
Anything in category (1) is handled specially according to what it is in particular. Everything else is passed to So the function
This is all entirely implementable in es, except for one critical problem, illustrated by the following example:
Why does actually calling the function work, but The shell doesn't actually use (Asymmetrically, the default definition of There is a possible way to resolve all of this, a somewhat-awful hack called |
Beta Was this translation helpful? Give feedback.
-
Thanks for the help and the great in-depth explanation! I can't vouch for the benefit of moving name resolution out of c and into es, but I can understand the desire to minimize the c core. I've read that discussion post and there doesn't seem to be an argument for it beyond putting the idea out there. Is it really a case of diminishing returns, or do you foresee it being of great benefit if done this way?
I think any user would expect the resolution to follow the environment layers from inner to outer; that is, the guest environment takes precedence over the host environment. I believe that's what other environments which allow this do, or at least I remember it being that way. I suppose added nuance here would be ensuring you don't do this when the call is explicitly foo.exe, lest you end up searching for a supposed foo.exe.exe |
Beta Was this translation helpful? Give feedback.
-
It's been a long time since I first implemented this so I can't recall exactly what was in my heart at the time, but I think I was initially motivated by minimalism. It was part of a larger effort to identify and minimize calls from C into es, and rename them from This minimalism is nice, but when it has tradeoffs like the introduction of a primitive as semantically ugly (and powerful) as
Yeah, I think this makes most sense.
Oh, good call, I didn't even think of that. If you wanted, you could even prompt the user in the "fallback" cases, like
|
Beta Was this translation helpful? Give feedback.
The quick answer:
%pathsearch
is the function you want to override. I'm not so familiar with WSL so there might be some gotchas I don't know about, but a somewhat quick-and-dirty override might look like:There's a little nuance with this that you might want to figure out for yourself. For example, if you have a
path
of/bin /usr/bin
, and your system has both a/bin/foo.exe
and a/usr/bin/foo
, which of those two binaries do you want returned forfoo
? That said, this should be an okay start.More in-depth technical discussion follows.
In es, every com…