cash icon indicating copy to clipboard operation
cash copied to clipboard

interpolation (aka command substitution)

Open khuongduybui opened this issue 10 years ago • 5 comments

Let's say I have a which command, I want to

$ which code
C:\Program Files (x86)\Microsoft VS Code\bin\code.cmd
$ echo "Here is your path to code: $(which code)"
Here is your path to code: C:\Program Files (x86)\Microsoft VS Code\bin\code.cmd

khuongduybui avatar Mar 14 '16 16:03 khuongduybui

I don't think this is supported yet, but we may be able to add support for this without too much trouble.

@dthree we could probably solve this by looking for this pattern during pre parsing and recursively calling vorpal on the string, right? Or would the vorpal instance not be available there?

nfischer avatar Mar 14 '16 17:03 nfischer

@khuongduybui very good point.

@nfischer I definitely want to add this, but then again I really, really want to add all of the bash functionality, and so adding this now would be double work.

I know I haven't been active recently on it, I've had no time. But trying to get some time soon.

dthree avatar Mar 14 '16 21:03 dthree

I'll take a look and see how easy it is. If it's not too much, I think we can just add the feature now and reimplement with the full bash parser later on down the road

nfischer avatar Mar 14 '16 22:03 nfischer

K awesome.

dthree avatar Mar 14 '16 22:03 dthree

So I looked into this. We would essentially need to instantiate the preparser using the same vorpal instance. From there, the parsing is pretty simple. I can write something up for this. The only messy part is that we have to explicitly pass the vorpal instance around, or make the preparser an attribute of the vorpal instance.

nfischer avatar Mar 19 '16 00:03 nfischer