sdether / josh.js

Toolkit for building a bash-like shell in the browser, including full readline support
http://sdether.github.com/josh.js/
Apache License 2.0
390 stars 76 forks source link

Is possible to execute js code in the shell? #38

Open teone opened 8 years ago

teone commented 8 years ago

Hey, I'd like to use this shell to create a tutorial on basic js command, is somehow possible to execute js code in the console?

Thanks

ghost commented 7 years ago

You can create a command that executes a JavaScript code string using eval().

Example:

shell.setCommandHandler("eval", {
    exec: function(cmd, args, callback) {
        callback(eval(args.join(" ")));
    }
});

// Shell
[1] $ eval "Hello, world!"
Hello, world!