Using jsish
Not logged in


There are a number of different ways to invoke jsish:


Interactive mode is the easiest way to try out Jsi, eg:

# var a = [1,2,3];
# for (var i in a) { puts(a[i]); }

Note, if running the precompiled (static) Linux executable, command-line editing is available via rlwrap:

rlwrap ./jsish

Running Scripts

Script-file to be executed are given as the first argument:

jsish prog.js arg1 arg2

We can make a script directly executable under unix, by setting the first line of the script with #!:

#!/usr/bin/env jsish
for (var i in console.args)


To see the supported switches in jsish use -h

jsish -h

Which outputs:

usage: jsi -h|--help|-v|--version|-d|--debug|-D|--debugui|-W|--websrv|-S|--safe|-Z|--zip|-H|--htmli|
	-J|-jsi|-C|--cssi|-i|--invoke CMD|-e|--eval SCRIPT|-T|--typecheck OPT|-IOPT VAL|FILE arg arg ...

The available switches are:

Options Description
-h|--help Outputs jsish help, or module help
-v|--version Output jsish version information
-d|--debug Command-line debugger (module)
-D|--debugui Jsi web-based gui debugger (module)
-W|--websrv Web server and start browser (module)
-S|--safe Run a safe interpreter, script or interactive (module)
-Z|--zip File zip utility (module)
-H|--htmli Html preprocessor (module)
-J|-jsi Javascript preprocessor (module)
-C|--cssi Css preprocessor (module)
-i|--invoke CMD Invoke command module stored in /zvfs
-e|--eval SCRIPT Evaluate a script string from command-line
-T|--typecheck OPT Set function typechecking level
-IOPT VAL Set an option within interp

Help for module commands can similarly be displayed, eg:

jsish -d -h

Which outputs:

/zvfs/lib/JsiUtil.jsi:121: error: throw: 
A command-line Debugger for Jsi scripts.

	-debug	 	0		// Debugging level
	-echoCmd 	true		// Echo user cmds.
	-safe	 	false		// Debug program in a safe interp (untested)



Javascript can be evaluated inline with -e, eg:
jsish -e 'var i = 0; while (i++<10) puts(i);'


Various commands in Jsi take an options object to parameterize behaviour. For example:

var db = new Sqlite('/tmp/testsql.db',{maxStmts:1000, readonly:true});
db.conf( {debug:1} );
puts( db.conf() );

In the case of object commands, a conf() method is provided for accessing options, post creation.

For example, we can use Interp.conf() for accessing interpreter options:

Interp.conf(); // Dump all options
Interp.conf('strict'); // Get one option
Interp.conf({strict:false, maxDepth:99}); // Set one or more options.

Note that options marked as initOnly may only be set at interpreter creation time, and readOnly not at all.

Internally, option parsing is implemented via C-Options.


There are several levels of introspection built-in to Jsi. The conf() method above is just one example.

Another is Info.cmds() which allows inspection of available commands:

# Info.cmds()
[  "Array", "Boolean", "File", "FileIO", "Function", "Interp", "Info", "JSON", "Math", "Number",
   "Object", "RegExp", "Signal", "Sqlite", "String", "Sys", "Websocket", "Zvfs", "assert", "clearInterval",
   "console", "decodeURI", "encodeURI", "exit", "source",
   "isFinite", "isNaN", "load", "parseFloat", "parseInt", "puts", "quote",
   "setInterval", "setTimeout", "format" ]

# info.cmds('Array.*')
[ "Array.concat", "Array.filter", "Array.forEach", "Array.indexOf", "Array.isArray", "Array.join",
 "Array.lastIndexOf", "Array.map", "Array.pop", "Array.push", "Array.reverse", "Array.shift", 
 "Array.sizeOf", "Array.slice", "Array.some", "Array.sort", "Array.splice", "Array.unshift" ]

Another manifestation of introspection shows up when an invalid method is called, eg:

  # info.xxx()
  error: 'info', sub-commands are: cmds data error event executable funcs interp keywords named platform revisions script vars version.    (at or near "xxx")

Example Applications

Jsi is distributed with several demonstration web applications:

These can all be run as standalone applications.


On Linux, you can setup .bashrc with autocompletion for Jsi using make setup.

Then (once you restart) typing TAB will perform autocompletion. This makes running jsish from the command-line a little nicer.



If you use the convenient Geany editor with Jsi, you can enable file completion in Geany:

Geany can also navigate through Jsi's gcc style scripting errors:

Now hit F8 to run the script. Upon errors, you should be able to navigate to the highlighted lines, and see warnings in the bottom pane.

Alternatively, you can just create a Makefile that runs jsish.

Note: a function with a return type will likely not show up in the symbols list in Geany.


Here is how to setup vim:
:set filetype javascript
:set makeprg=jsish\ %

Then to run scripts just use: