REPL for Windows Host Script engines JScript and VBScript #11411

Closed
opened 2026-01-31 02:46:55 +00:00 by claunia · 2 comments
Owner

Originally created by @Foadsf on GitHub (Nov 15, 2020).

Description of the new feature/enhancement

I know WSH is not very popular, but wscript.exe and cscript.exe are shipped with almost all Windows machines out there. IMHO it could be a nice idea to provide a simple interactive read–eval–print loop (REPL) for JScript and VBScript.

Proposed technical implementation details (optional)

A primitive version of the JScript REPL inspired by Node.js, written in JScript:

var inputLine = ".start";

var findVariableName = /^[ ]*(var[ ]+)?([_A-Za-z][_A-Za-z0-9]*)[ ]*=([^=][ ]*[^\n;,]*);?/;
var temporaryRegexResult;

function print(inputVariable) {
    var outputString;
    if (inputVariable instanceof Array) {
        outputString = "[" + myArray.join(", ") + "]";
    } else if (inputVariable == null) {
        outputString = "undefined";
    } else {
        outputString = inputVariable;
    }
    WScript.StdOut.WriteLine(outputString);
}

do {
    if (inputLine != ".start") {
        try {
            eval(inputLine);

            if (findVariableName.test(inputLine)) {
                eval("print(" + RegExp.$2 + ");");

            } else {
                eval("temporaryOutput = (" + inputLine + ");");
                print(temporaryOutput);
            }

        } catch (error) {
            print(error.message);
        }
    }

    WScript.StdOut.Write("> ");
    inputLine = WScript.StdIn.ReadLine();
} while (inputLine != ".exit");
Originally created by @Foadsf on GitHub (Nov 15, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> I know WSH is not very popular, but `wscript.exe` and `cscript.exe` are shipped with almost all Windows machines out there. IMHO it could be a nice idea to provide a simple interactive read–eval–print loop (REPL) for JScript and VBScript. # Proposed technical implementation details (optional) <!-- A clear and concise description of what you want to happen. --> A primitive version of the JScript REPL inspired by Node.js, written in JScript: ~~~javascript var inputLine = ".start"; var findVariableName = /^[ ]*(var[ ]+)?([_A-Za-z][_A-Za-z0-9]*)[ ]*=([^=][ ]*[^\n;,]*);?/; var temporaryRegexResult; function print(inputVariable) { var outputString; if (inputVariable instanceof Array) { outputString = "[" + myArray.join(", ") + "]"; } else if (inputVariable == null) { outputString = "undefined"; } else { outputString = inputVariable; } WScript.StdOut.WriteLine(outputString); } do { if (inputLine != ".start") { try { eval(inputLine); if (findVariableName.test(inputLine)) { eval("print(" + RegExp.$2 + ");"); } else { eval("temporaryOutput = (" + inputLine + ");"); print(temporaryOutput); } } catch (error) { print(error.message); } } WScript.StdOut.Write("> "); inputLine = WScript.StdIn.ReadLine(); } while (inputLine != ".exit"); ~~~
claunia added the Issue-FeatureResolution-ExternalNeeds-Tag-Fix labels 2026-01-31 02:46:55 +00:00
Author
Owner

@DHowett commented on GitHub (Nov 15, 2020):

We talked on twitter and I let @Foadsf know about @PhMajerus's AXSH. Seems to be what they wanted 😄

In general, this is a good place for a third party developer to take up the charge. It doesn't have to be part of the Terminal project!

@DHowett commented on GitHub (Nov 15, 2020): We talked on twitter and I let @Foadsf know about @PhMajerus's AXSH. Seems to be what they wanted :smile: In general, this is a good place for a third party developer to take up the charge. It doesn't have to be part of the Terminal project!
Author
Owner

@Foadsf commented on GitHub (Nov 22, 2020):

@DHowett I have written a REPL myself. And I realized that I can add it to the setting.json. It seems to be working fine for now. I will FLOSS the code and then you might think of adding or not adding it to the Windows Terminal.

JScript.js inside Windows Terminal

@Foadsf commented on GitHub (Nov 22, 2020): @DHowett I have written a REPL myself. And I realized that I can add it to the `setting.json`. It seems to be working fine for now. I will FLOSS the code and then you might think of adding or not adding it to the Windows Terminal. ![JScript.js inside Windows Terminal](https://i.imgur.com/121FWRZ.png)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#11411