AIn the first form, the source file is copied to the destination, and then deleted. This is the same as the rename command, except you can move files across devices.
In the second form, one or more files are copied into the destination, which should be a directory.
Filenames
Filename-expansion
The Command Line
Batch files
AWhen <Tab> (or any user-defined key set to "expand") is pressed the shell attempts to expand the string to the LEFT of the cursor into a filename. If there is no unique match the bell is sounded and a partial expansion (of the common pathname parts) is displayed. Expanding this again immediately displays the possible completions.
The filenames are delimited by the beginning of the line, a space or a comma.
AThis window is displayed at the bottom of the screen whilst the shell is initializing and can be toggled at any time by the "toggle-log" toolbar button, or the user-defined key set to the "log"
function. Status messages are permanently stored and can be displayed in this window, using PgUp and PgDn to scroll through the messages.
Messages can be stored in the log with the logger command.
chmod
date
dirs
Toolbar
Variables
alias
&ADisplays a hexadecimal dump of the file.If the file exceeds one screen-full, the output pauses, displaying '<OD>' in the bottom left corner. If <RETURN> is pressed the next line will be displayed. If 'q' or <ESC> is pressed the command will terminate. Any other key will display the next page.
bindkey
bindkey
banner
ver
which
path
path
unset
which
path
toolbar (variable)
dirs
more
pause
hash
pause
history
banner
cat
bindkey
List of shell variables
List of commands:
cls
echo
edit
exit
goto
hash
logger
help
history
log
_ADisplays the contents of the specified file. This command only works correctly for text files. If the file exceeds one screen-full, the output pauses, displaying '<MORE>' in the bottom left corner. If <RETURN> is pressed the next line will be displayed. If 'q' or <ESC> is pressed the command will terminate. Any other key will display the next page.
mkdir
more
$APauses for a time determined by the value specified. If the interval is 0 or not supplied the program will wait until a keyis pressed. If the interval is positive, the program will pause for interval/20 seconds. If the value is negative, the program will also restart after a key is pressed.
popd
pushd
pause
rename
rename
rescan
pwd
rescan
rmdir
AChanges the position of the parameters in a batch file such that $2 becomes $1, $3 becomes $2 and so on. $0 will always be the name of the batch file. $# will be decremented to refect the number of parameters.
The number of places to shift can optionally be specified.
shift
sysinfo
set
sysinfo
unalias
unset
time
unset
Arial
Arial
Times New Roman
AThis program provides some of the functions of shells found on UNIX or DOS computers. Basic file operations are supported (move, copy, delete, etc) and input/output redirection as well as a 'pipe' like facility for passing data between commands.
Features include shell variables, aliases, macros, command line editing, filename completion, command history and an easy extension mechanism.
Sketch
UUUUUUUUUU
DEEEEEEEEEE
DGGGGGGGGGG
@EEEEEEEEEE
PQQQQQQQQQQ
PQQQQQQQQQQ
PQQQUUUQQQQ
SQQQUUUQQQQ
&Paint.app
XAWithout arguments, this reads input from the keyboard a line at a time and displays this to the screen. Input is terminated by pressing <ESC> on an empty line.
This command is only really useful when the output is redirected to a file. Then it can be used to concatenate files together, or add text to the end of a file from the keyboard.
nt line.
Log window
Macros
ver
which
AThe following command descriptions use these conventions:
Parameters in angle brackets <> are mandatory.
eg. rename <file1> <file2>
Parameters in square brackets are optional.
eg. pause [interval]
Choices of possible options are indicated by
eg. ls [-s
-l] [filename]
AThis measures the time taken to execute a command. Only one time command can be used per input line, and in the case where pipes or ";" are used, only the first occurrence is significant and the time returned will be for all remaining commands on the line.
BBatch files are text files with a suffix .bat that contain shell commands to be executed. Conditional execution is provided by the IF and GOTO contructs. The syntax is very similar to MS DOS batch files.
Command line parameters given to batch files are accessed via $1,$2,..,$9 (or %1,%2,...%9 depending on the setting of unixvar). The 10th and higher parameters are accessed by using the shift command.
$0 always contains the name of the batch file (ie. shift doesn't affect it).
$# contains the current number of parameters.
$? contains the return value of the previous command.
e.g. If install.bat contains the commands:
cp program.opo $1$:/opo
The command "install c" will execute:
cp program.opo c:/opo
Courier
Courier
Courier
AWherever a filename is specified as the argument to a command, either a full or relative pathname can be given. Relative pathnames use "." to signify the current directory and ".." to specify the parent one.
e.g. If the current directory is C:/Documents, the following commands will have the same effect:
cp C:/Documents/*.bat C:/store/
cp *.bat /store/
cp /Documents/*.bat ../store
AWith no arguments, all the commands in the hash table and their corresponding full paths are displayed. Otherwise the entry for the supplied command is shown.
Options: -r Removes the given command from the hash table. If no command is supplied, all entries are cleared.
1AThe four toolbar buttons are used in the same way as macros. Their functions are determined by the contents of the variables $button1 .. $button4. As with macros a leading "@" character causes the contents to be executed.
eg. set button1 "@logger -t"
set button2 "@set toolbar off"
set button3 "@exit"
/CShell variables are accessed by prepending the variable name with '$' or '%'. The variable unixvar determines which character is used as follow:
set -o unixvar $ (default)
set +o unixvar %
eg. set fred="text string"
echo $fred
To append text to a variable use '$variable$'
eg. set path=C:\bin
set path=$path$,D:\bin
To use '$' anywhere other than specifying a variable use quotes - "$".
A special construct is ${expression}. The expression is evaluated using the OPL 'EVAL()' command. Amongst other things this allows arithmetic operation on shell variables, as well as GET, KEY, etc.
eg. set n=${$n+1} Increments the variable n.
Variable names are case SENSITIVE - ie. $path and $PATH are treated as entirely separate variables.
Special system read-only are denoted by a leading underscore.
4AIf 'filename'is a directory, files within the directory are listed, otherwise filenames matching the specification 'filename' will be listed. If no filename is given the current directory is listed.
Options: -l Display modification time and file attributes for each entry.
-s Display file size and type.
Courier
Courier
Courier
Arial
Courier
Courier
Courier
Courier
Arial
Arial
Arial
Courier
Courier
Courier
Courier
Courier
Courier
MAPush a directory onto the directory stack.
+n: Rotates the stack so that the nth directory (counting from the left of the list shown by dirs, starting with zero) is at the top.
-n: Rotates the stack so that the nth directory (counting from the right of the list shown by dirs, starting with zero) is at the top.
See also: dirs popd
/store
GThis facility allows certain key sequences to remapped to specific functions. This allows the following operations:
Shell functions can be duplicated on other keys, eg. define Control-p and Control-n to scroll through the history.
Shell3a "special" keys can be redefined, eg. define TAB to display the log window.
Single characters can be mapped to a key combination, eg. Fn-k to the
symbol.
Multiple characters can be mapped to a key combination. eg. Control-z could be defined to produce the string Z:\. This will behave the same as if the line had been typed in.
A string of characters can be mapped to a key combination and this string is then EXECUTED. Any results will be printed to the screen but will NOT form part of the input text. This could be used to execute an arbitrary command for when, say, the MENU key was pressed. Any valid shell commands, including pipes may be used.
For the last two there is a limit of 16 strings / commands that can be assigned to keys. These are stored in the variables macro1 to macro16. These variables can be altered at will or even deleted and the keys to which they are assigned will pick up the new definitions.
Notes
Macros, remapped keys and toolbar buttons are only recognized at the command prompt.
The key combinations that can be remapped are Fn A-Z, Ctrl A-Z, and special keys such as the cursor keys, TAB, HELP, MENU, etc. Most of these keys can also take the Shift modifier.
See the help for the bindkey command for details on defining keys.
WARNING: It is perfectly possible to redefine keys such as Delete, Esc and Enter (it's potentionally useful), and unless you've defined another key combination to perform their function you may render the shell unusable (eg. no Enter
function) and will have to restart the application.
AWithout any arguments this will call up the Shell5 help file (this file!). An alternative one can be specified (don't append .hlp to the filename). The search path for help files is set in the shell variable $helppath. If the help file is already open (from the same session) the program will switch to it rather than starting one anew. If the shell is exited "nicely" either via "exit" or the task list, open help sessions will be closed.
Options: -l List .hlp files in $helppath
)DMany commands can send their output to a file instead of the screen. eg.
command > file
OR command >> file
These commands are identical except that if the file exists, ">>" appends the output to the file and ">" trucates the file before writing. This behaviour can be changed via the append shell variable.
Some commands (cat, more, od and wc) can take their input from a file rather than command line parameters. eg.
more < file.txt
which would be the same as:
more file.txt
This mightn't seem useful, but input redirection is very useful for pipes.
Commands that don't use redirected input ignore it.
Pipes allow the output of one command to form the input of another.
eg. history
more
The
symbol is produced by either Fn-k or CTRL 166.
NOTES:
Pipes are implemented using intermediate files.
Each command runs to completion before the next is run.
Errors produced by the shell (e.g. for bad wildcards) will terminate the pipe immediately.
Errors produced by commands in the pipe will be reported, but remaining commands will run.
Macros
Filename-expansion
#Output/Input-Redirection and Pipes
Variables
Batch files
Log window
which
FASend a message to the system log window. With no arguments the log window is displayed (if it was hidden).
Options: -c Clear the log
-b Scroll the log back one entry
-f Scroll the log forward one entry
-r Remove the log window
-t Toggle the display of the log window
-a Append the message to the current line.
alias
With no arguments displays the current aliases. With a single argument, displays the alias defined (if it exists) for [string1]. With 2 arguments, the alias for [string1] is defined as [string2].
!Usage: alias [string1] [string2]
NSets the current screen printing position. 1,1 is the top left of the screen.
Usage: at <xpos>,<ypos>
banner
Prints the string in large letters. The default character of which the letters are composed is '#', but another can optionally be supplied.
rCopies the source file either to the destination file, or if the destination is a directory, into this directory.
!Usage: cp <source> <destination>
date
$Displays the current time and date.
Usage: date
/Gives a summary of all connected disk devices.
Usage: df
echo
WOutputs the specified text to the screen. Without arguments a blank line is displayed.
$Usage: echo [string1] [string2] ...
chmod
iSets (+) or clears (-) the specified attributes R (read-only), H (hidden) and S (system) of the file(s).
*Usage: chmod [+
-] [R] [H] [S] <filename>
edit
Calls up the mini text editor with the contents of the specified file. The file can be arbitrarily large, but you can only ADD 8KB of text in each edit session.
Usage: edit <filename>
goto
A label is set within a batch file using either a leading colon or two trailing colons. 'GOTO label' jumps to the statements immediately following the label.
eg. label::
GOTO label
Courier
Courier
Courier
Courier
)Usage: goto <label> (batch files only)
XAIf the condition specified is true, <statement> is carried out, otherwise it is ignored. Any command, including another IF can form the statement part.
eg. IF not exist /System echo "Fatal error"
IF $1 == "C" ls C:/
The third (new) variation will execute <statement> if <string1> is NOT empty and NOT "0".
eg. IF ${$a>3} echo a is more than 3
Arial
Courier
Courier
Courier
Arial
Courier
Arial
Courier
EThis entry lists the shell variables that have special meanings.
cwdcmd Values: command
If the cwdcmd option is set, the command in $cwdcmd is executed whenever the current directoy is changed
font Values: font,style
Specifies the font and style to use. If the style is not specified, the existing one is used. If the font is specified as '-1', only the style is changed.
eg. set font=268435970,17
helppath Value: Comma separated list of directories.
These are the directories that are searched for the system help file, shell5.hlp, and help files for additional commands.
eg. set helppath="C:/help,D:/help"
history Value: Number
The number of previous commands to store in the history.
path Value: Comma separated list of directories
Specifies the search path for executable files. "." represents the current working directory.
eg. set path="C:/opo,D:/opo,."
prompt Value: String
Defines the string printed to the left of the command input. Special entries are listed below and are denoted by '%' ('$' if unixvar is set to 'OFF'):
%H the current history number
%P the current working directory.
%p the right-most component of the current working directory.
%% % sign.
toolbar Value: ON, OFF or TOGGLE
If ON, the Psion toolbar panel is displayed.
_cwd Value: Read-only
The current working directory
_syspath Value: Read-only
The directory in which the program is installed.
_shellopt Value: Read-only
A summary of the currently set shell options.
Courier
Courier
Courier
Courier
Arial
Courier
Courier
Courier
Courier
Courier
Courier
Courier
FWith no arguments prints the current key definitions. With a single argument, prints the current definition of that key. If the key is followed by :definition the key will be redefined.
Key Definition
The key to be defined can be of 3 types:
1) A "special" which is one of: left, right, up, down, menu, delete, enter, space, esc or tab.
2) The Fn (function) key followed by an alphabetic character. eg. Fn-r.
3) The Ctrl (control) key followed by an alphabetic character. eg. Ctrl-e.
Any of the above can also take the shift- modifier. eg. Shift-enter.
Action Definition
The action to be performed by the key is one of
A single character. eg. bindkey Fn-k:
A special shell operation (see below for a list). eg. bindkey C-n:next
A string of characters. eg. bindkey Ctrl-z:"Z:/"
A command to be executed.
eg. bindkey Ctrl-l:"@cls".
The "@" tells the shell that this string is to be executed rather than just appear as a string on the command line.
A previously defined or to-be defined macro value. These are designated macro1 to macro16 and are normal shell variables.
eg. bindkey ctrl-e:"@exit"
is equivalent to
bindkey ctrl-e:macro1
set macro1 "@exit"
Shell Operations
Operation Default Key Description
delete Delete, Ctrl-h Delete character to left
delete-right Shift-Delete Delete character to right
enter Enter, Ctrl-m Enter
esc Esc Clear input line
previous Up Arrow Scroll up through history
next Down Arrow Scroll down through
history
right Right Arrow Move cursor right
left Left Arrow Move cursor left
first PgUp Start of history,
scroll log up
last PgDn End of history,
scroll log down
start Home Start of command line
CWith no arguments the current value of all the variables are displayed. If no value is supplied the variable is unset.
See the "Variables" section of the help for variables that have special meanings.
The +/-o option sets flags that determine the shell's behaviour. The -o option on it's own displays the current state of each flag; the +o option generates output that can be directly used in a batch file to duplicate the current state. The flags are:
append If set, output redirection using '>' will act
as though '>>' was specified.
cwdcmd If set, whenever the current working
directory is changed the command in
$cwdcmd is executed.
echo If set, the commands in a batch file are
printed as they are executed.
unixpath If set, '/', rather than '\' is used as the
filename separator (although backslash
can still be used too).
unixvar If set, shell variables are denoted by
'$name', other-wise by '%name'.
Shell 5
Introduction
NO WARRANTY
exit
Within a batch file, immediately stop processing the current file. If the optional number parameter is supplied the exit code (accessed via $?) is set to this.
At the command prompt this command will terminate the program.
exit [number]
Toolbar
Courier
Courier
Courier
List of shell variables
,ECommands are entered via the command line. Normal Psion editing keys work - left, right, home, end etc. Additionally the up and down keys access previously entered commands, with PgUp and PgDn accessing the first and last availabe commands respectively (except when the log window is on screen). The number of saved commands is set with the history variable and the history command displays the current history. User-defined macros and toolbar buttons are also available.
The input line is first matched against any aliases that have been defined. Aliases are a way of creating shorthand versions of long commands. Any input after a "#" symbol is ignored, so it can be used for comments in batch files.
Next it's matched against the 43 built in commands (listed below). If none of these match, the path is searched for a file matching the name - either a batch file (.bat), a translated OPL program (.opo) or an application (.app).
The shell supports 2 sorts of .opo files - specifically written external shell commands or generic .OPO programs. If a directory is found instead, your current directory is set to this. This can be used as a shorthand for "cd".
Multiple commands can be put on a single line if they are separated with the ';' character.
(Please read the README file for details on adding new commands)
shift
+Usage: shift [places] (batch files only)
time
+Usage: time [command] (interactive only)
unalias
-Removes the alias for <string> if it exists.
Usage: unalias <string>
unset
EDeletes the named variable. This is equivalent to "set <variable>=".
Usage: unset <variable>
ver
#Displays the version of the shell.
Usage: ver
which
For the supplied command gives either the alias information, identifies it as a buillt-in function or gives the pathname of the external command.
Usage: which <command>
bindkey
"Usage: bindkey [key[:definition]]
dirs
Print the directory stack, the most recent to the left; the first directory shown is the current directory.
See also: pushd popd
Usage: dirs
pushd
Usage: pushd <+n
directory>
popd
OPop the directory stack and cd to the new top directory.
See also: dirs pushd
Usage: popd
log
+Usage: log [-c
-t] ["message"]
sysinfo
SDisplays various information about the machine - battery status, ROM version, etc.
Usage: sysinfo
The Command Line
Filenames
Courier
Courier
Courier
List of commands:
hash
Usage: hash [-r] [command]
history
Displays commands in the history buffer. The number of commands available depends on the value set for the 'history' shell variable. To view long histories the output can be piped into the 'more' command.
Usage: history [number]
Arial
Courier
Courier
Arial
Courier
|Usage: if [not] exist <pathname> <statement>
if [not] <string1> == <string2> <statement>
if [not] <string1> <statement>
Usage: ls [-l
-s] [filename]
help
Usage: help [-l] [help file]
mkdir
!Creates the specified directory.
Usage: mkdir <directory>
more
Usage: more [file]
9Usage: mv <file1> <file2>
mv <file1> <file2> ... <dir>
Usage: od [file]
pause
Usage: pause [interval]
pwd
(Displays the current working directory.
Usage: pwd
rename
(Renames the supplied file or directory.
Usage: rename <source> <target>
rescan
Check for any attached devices. This command must be used in order for newly attached devices to be accessed. Please note that this command resets the current working directory on all devices.
Usage: rescan
_Deletes the specified files.
Options: -r Recursively delete a directory and all its contents.
Usage: rm [-r] <filename>
rmdir
!Deletes the specified directory.
Usage: rmdir <directory>
set
)Usage: set [-
+o] <variable> [=] [value]
$c:\Documents\Programs\Shell5\sh5_0211
SCRWID%
SCRHGHT%
TBARLINK
z:\system\opl\Toolbar
_mainO
_STAT%
_KEY%
_SPEC$
_BLTIN$
_CURR&
_PID%
_HASH&
_DIRB&
_DIRC&
_ATAB&
_CWD$
_HPOS&
_HNUM%
_HSZ%
_HRSZ%
_CPOS&
SCRINFO%
_OPTS%
_OPTS$
_OUT%
ARGV&
_VARS&
_KEYS&
_SYSPATH$
_HERE$
_LOGID%
_LOGW%
_LOGH%
_LOGS&
_LOGN%
_LOGL%
_EXTEVENT%
_PUSHC&
_HELP&
_SNDSTAT&
_STYLE%
_ACT$
_INIT
GETVAR$
_MKPR$
_GETIN$
_PROC%
_EXIT
promptO
{IWC_
{IWCO
Fatal:
FPARSE%
PARSE%
PRPATH$
_VARS&
_HERE$
_SYSPATH$
_OPTS%
O@\[e
O#@[$
O94\[X
{IWCW
{IWCW
{IWCW
pipe.K 0
O!hD\[
O!h@[
O \[n
_OUT%
_STORE%
_SYSPATH$
O!\O @[
O@\\[(
pipe.K
O!\O @[!
_CHKP%
ARGV&
_OUT%
_BLTIN$
{IWCW
PARSE%
STAT%
_HSHF$
FPARSE%
_RUN%
_OPTS%
_OUT%
ARGV&
batG\
appG\[
bat,opo,app,
opoC[]
batC[
appC[.
O$h@[
O {IWC
Not a valid application
O!h@[
Oah@W
Och@`[2
Command not found
FPARSE%
GETVAR$
_PATH$
_HASH&
batG\
appG\[
bat,opo,app
pathO
{IO {I
FPARSE%
STAT%
Bad path component:
_OPTS%
_OPTS%
_DIRB&
_DIRC&
O\@[y
..C[F
_EDIT%
_CPOS&
_HPOS&
_LOGID%
{IWC_
{IWCO
O @['
{IWC $
{IWCW
_EXIT
TBAROFFER%
GETVAR$
_EXPAND$
_PROC%
SCRINFO%
_EXTEVENT%
_KEYS&
_CURR&
O {]_
Oz4\`[
button
macro
O@D[r
_AFIND$
_INPAR%
_SUBPR%
_CLRA
_STAT%
_KEY%
_CURR&
_PID%
_SPEC$
_SYSPATH$
_HERE$
O.hD[
{IWCW
timeC[i
Nested times not allowed
{IWCO
{IWCO
O.hD[*
O {IW
pipe.K
Elapsed time:
pipe.?K
FPARSE%
_CLRA
{IWCW
notC[/
{IWCW
existC[H
{IWCW
{IWCW
==C[A
{IWCW
0G\[
_ATAB&
_SPEC$
{IWCW
{IWCW
{IWCW
TBARSHOW
TBARHIDE
_SETW%
_HSZ%
_HRSZ%
_HPOS&
_CPOS&
TBVIS%
_HASH&
SCRINFO%
_STYLE%
_VARS&
historyC[
toolbarC[
toggleC[
offC[
pathC[7
fontC[
{IWCW
{IWCO
{IWCO
_VARS&
{IWCW
{IWCW
_VARS&
{IWCW
- Variable not set
PRPATH$
_SPEC$
_HNUM%
_CWD$
PARSE%
STAT%
O hD[
O h@`[
O!hD[
_INPAR%
_AFIND$
_SUBPR%
_CLRA
_STAT%
_KEY%
_CURR&
_PID%
_OPTS%
_HERE$
_SPEC$
_SYSPATH$
O.hD[
O$hD[
O$h@[
"'*?{} =+-/# !
P{IWC
{IWCW
O:@["
{IWCW
{IWCW
DEBUG: Duplicate label.
gotoC[
Bad GOTO
{IWCW
{IWCO
O.hD[#
O {IW
pipe.K
No such label:
DEBUG: How did xpa& get set?
pipe.?K
PARSE%
XSTAT%
PRPATH$
_STAT%
_KEY%
_OPTS%
SCRINFO%
O.hD[
O.hD[*
O h@[
O.hD[*
Ooh@[
Argument overflow
Wildcards not allowed
OGh@[
Buffer overflow
O!h@["
No such file or directory
Not a directory
Must be a directory
Not a plain file
No match
+0Input/output redirection invalid for batch files