JNode Shell
Introduction
The JNode command shell allows commands to be entered and run interactively from the JNode command prompt or run from command script files. Input to entered at the command prompt (or read from a script file) is first split into command lines by a command interpreter; see below. Each command line is split into command name (an alias in JNode parlance) and a sequence of arguments. Finally, each command alias is mapped to a class name, and run by a command invoker.
The available aliases can be listed by typing
JNode /> alias<ENTER>
and an aliases syntax and built-in help can be displayed by typing
JNode /> help alias<ENTER>
More extensive documentation for most commands can be found in the JNode Commands index.
Keyboard Bindings
The command shell (or more accurately, the keyboard interpreter) implements the following keyboard events:
<SHIFT>+<UP ARROW> | Scroll the console up a line |
<SHIFT>+<DOWN-ARROW> | Scroll the console down a line |
<SHIFT>+<PAGE-UP> | Scroll the console up a page |
<SHIFT>+<PAGE-DOWN> | Scroll the console down a page |
<ALT>+<F1> | Switch to the main command console |
<ALT>+<F2> | Switch to the second command console |
<ALT>+<F7> | Switch to the Log console (read only) |
<ESC> | Show command usage message(s) |
<TAB> | Command / input completion |
<UP-ARROW> | Go to previous history entry |
<DOWN-ARROW> | Go to next history entry |
<LEFT-ARROW> | Move cursor left |
<RIGHT-ARROW> | Move cursor right |
<BACKSPACE> | Delete character to left of cursor |
<DELETE> | Delete character to right of cursor |
<CTRL>+<C> | Interrupt command (currently disabled) |
<CTRL>+<D> | Soft EOF |
<CTRL>+<Z> | Continue the current command in the background |
<CTRL>+<L> | Clear the console and the input line buffer |
Note: you can change the key bindings using the bindkeys command.
Command Completion and Incremental Help
The JNode command shell has a sophisticated command completion mechanism that is tied into JNode's native command syntax mechanisms. Completion is performed by typing the <TAB> key.
If you enter a partial command name as follows.
JNode /> if
If you now enter <TAB> the shell will complete the command as follows:
JNode /> ifconfig
with space after the "g" so that you can enter the first argument. If you enter <TAB>
again, JNode will list the possible completions for the first argument as follows:
eth-pci(0,16,0)
loopback
JNode /> ifconfig
This is telling you that the possible values for the first argument are "eth-pci(0,16,0)" and "loopback"; i.e. the names of all network devices that are currently available. If you now enter "l" followed by <TAB>, the shell will complete the first argument as follows:
JNode /> ifconfig loopback
and so on. Completion can be performed on aliases, option names and argument types such as file and directory paths and device and plugin names.
While completion can be used to jolt your memory, it is often useful to be able to see the syntax description for the command you are entering. If you are in the middle of entering a command, entering <CTRL-?> will parse what you have typed in so far against the aliases syntax, and then print the syntax description for the alternative(s) that match what you have entered.
The JNode command shell uses a CommandInterpreter object to translate the characters typed at the command prompt into the names and arguments for commands to be executed. There are currently 3 interpreters available:
- "default" - this bare-bones interpreter splits a line into a simple command name (alias) and arguments. It understands argument quoting, but little else.
- "redirecting" - this interpreter adds the ability to use "<" and ">" for redirecting standard input and standard output, and "|" for simple command pipelines. This is the default interpreter.
- "bjorne" - this interpreter is an implementation of the POSIX shell specification; i.e. it is like UNIX / GNU Linux shells such as "sh", "bash" and "ksh". The bjorne interpreter is still under development. Refer to the bjorne tracking issue for a summary of implemented features and current limitations.
The JNode command shell currently consults the "jnode.interpreter" property to determine what interpreter to use. You can change the current interpreter using the "propset -s" command; e.g.
JNode /> propset -s jnode.interpreter bjorne
Note that this only affects the current console, and that the setting does not persist beyond the next JNode reboot.
Command Invokers
The JNode command shell uses a CommandInvoker object to execute commands extracted from the command line by the interpreter. This allows us to run commands in different ways. There are currently 4 command invokers available:
- "default" - this invoker runs the command in the current Java Thread.
- "thread" - this invoker runs the command in a new Java Thread.
- "proclet" - this invoker runs the command in a new Proclet. The proclet mechanism is a light-weight process mechanism that gives a degree of isolation, so that the command can have its own standard input, output and error streams. The command can also see the "environment" variables of the parent interpreter. This is the default invoker.
- "isolate" - this invoker runs the command in a new Isolate. The isolate mechanism gives the command its own statics, as if the command is executing in a new JVM. Isolates and the IsolateInvoker are not fully implemented.
The JNode command shell currently consults the "jnode.invoker" property to determine what invoker to use. You can change the current invoker using the "propset -s" command; e.g.
JNode /> propset -s jnode.invoker isolate
Note that this only affects the current console, and that the setting does not persist beyond the next JNode reboot.
- Printer-friendly version
- Login to post comments