malxau/yori

Simple batch files don't work

Closed this issue · 2 comments

Create a batch file containing

cd c:\home\development

Run this batch file in cmd.exe and it will navigate to the specified path.
Run this batch file in Yori and it just echos the command.

What is the extension of the file?

If the file has a .bat or .cmd extension, it is executed by CMD. A child CMD process is launched, the directory is changed, that process terminates, and the Yori process is unaffected.

If the goal is to execute the script within Yori itself, it should have a .ys1 extension. In this case the command executes as part of the Yori shell and the directory change takes effect.

Note that the two shells do have different behaviors and scripts are not automatically interchangeable between them, which is why Yori is leaving CMD to execute CMD scripts. See http://www.malsmith.net/yori/guide/#scripting .

Yori does include a lot of fairly invasive logic to detect the side-effects of CMD scripts and propagate these back into the Yori shell process. This is done for aliases as well as environment variables. I haven't looked into doing this for the current directory; it may be possible, but there are no guarantees. This works by inspecting the memory contents of the CMD process when it is terminating, and doing so reliably across versions is not straightforward.

I see. That's fair enough then. I came across Yori reading a blog by Scott Hanselman and he described it as a drop in replacement for cmd.exe

https://www.hanselman.com/blog/YoriTheQuietLittleCMDReplacementThatYouNeedToInstallNOW.aspx

I use a small library of batch files for directory and workspace management and as a way to invoke utilities compiled from source without having to copy build outputs around or add build output directories into the system path.

It's not that big a library, I suppose I could duplicate all the files as .ys1 files and test it. I don't see anything in the documentation that describes what kinds of batch file commands might not be compatible though.