janino-compiler / jsh

jsh - The "Java Shell"
37 stars 6 forks source link

jsh - The "Java Shell"

Introduction

On popular operating systems (UNIX, MS WINDOWS, MAC OS, ...) exists a plethora of "shells", i.e. programs that read a sequence of "commands" (either from a "script file" or from the console) and execute them: Bourne Shell, BASH, C Shell, Korn Shell, only to mention a few.

JSH is yet another shell program that stands out from these wrt the following aspects:

These properties open up a whole range of new use cases which you would normally not implement with a shell script:

Usage

Get the latest version of the runnable JAR file from here, and run it:

$ java -jar jar-file

Now start typing Java code and see how it executes. Here's an example session:

Welcome, stranger, and speak!
$ System.out.println("HELLO WORLD");
HELLO WORLD
$ for (int i = 0; i < 3; i++) {
>     out("HELLO WORLD"); // Short for "System.out.println()".
> }
HELLO WORLD
HELLO WORLD
HELLO WORLD
$ for (String s : new String[] { "a", "b", "c" }) {
>     out(s);
> }
a
b
c
$ ls(); // Shorthand for "ls.$()".
.bashrc
.bash_history
.bash_profile
.jshrc
$ ls.l().$(); // "l()" activates "long" listing, resembling "ls -l".
-rwx paula\Arno        6437 20.09.2016 13:42:27 .bashrc
-rwx paula\Arno       50409 20.09.2016 13:42:28 .bash_history
-rwx paula\Arno        1494 22.01.2013 22:05:48 .bash_profile
-rwx paula\Arno          56 16.08.2015 20:32:00 .jshrc
$
exit();

For documentation of the available commands (like ls();), download the JAVADOC

https://oss.sonatype.org/content/groups/public/de/unkrig/jsh/_latest-version_/jsh-_latest-version_-javadoc.jar

, and check the documentation of the "JshBase" class.

Licensing

JSH is available under the new BSD license.

Contributing

If you find the concept useful, feel free to use JSH, give feedback, and contribute! The best way to contact me is via a GITHUB issue.