jsh(1) jsh(1)
NAME
jsh - Bourne shell with job control
SYNOPSIS
jsh [option ...] [argument ...]
DESCRIPTION
jsh is a Bourne shell (sh) with job control enabled in addition to the
normal functionality of the Bourne shell. This allows you to:
- stop jobs,
- move jobs to the background,
- bring jobs from the background to the foreground, and
- easily identify and access jobs via job numbers.
As a rule, job control can only be used in an interactive shell, i.e.
a login shell or a subshell. Shells running shell scripts do not bene-
fit from the added functionality of job control.
The enhancements provided by job control are the introduction of:
- identifiable jobs with various states,
- new shell built-ins, and
- extensions to existing shell built-in.
The possible entries for option and argument are discussed in detail
in the description of the Bourne shell sh. There is no difference
between the two shells in this respect.
MODE OF OPERATION
jsh treats every command or pipeline that the user enters at the ter-
minal as a job. All jobs exists in one of the following three states:
Foreground
A foreground job has read and write access to the controlling
terminal.
Background
A background job is denied read access and has conditional write
access to the controlling terminal [see stty(1)].
Stopped
A stopped job is a job that has been suspended, usually as a
result of a SIGTSTP signal [see signal(5)].
Page 1 Reliant UNIX 5.44 Printed 11/98
jsh(1) jsh(1)
Every job started by jsh is assigned a positive integer called a job
number, which is tracked by the shell and used as an identifier to
indicate a specific job. In addition, the shell keeps track of the
current and previous jobs. The current job is the most recent job to
be started or restarted. The previous job is the first non-current
job.
The acceptable syntax for a job identifier is:
%jobid
where jobid may be in any of the following formats:
% or +
the current job
- the previous job
?string
the job for which the command line uniquely contains string
num the job with job number num
prefix
the job whose command name begins with the string prefix. The
prefix must not contain blanks unless they are quoted.
Example: The ls -l ... command running in the background could be
referred to as %ls.
You can stop a job by sending a STOP signal to it with the key combi-
nation CTRL-Z. jsh will then indicate that the job has been stopped
and will display a prompt. The CTRL-Z combination produces an immedi-
ate response (like the interrupt key DEL).
Caution:
If you are using jsh together with shl, you must redefine the
switch character [see stty(1)] to prevent the suspend character
from being deactivated.
COMMANDS
The following additional shell built-ins may be entered after the PS1
prompt (default: $ ):
bg [%jobid ...]
Resumes the execution of a stopped job in the background. jobid
designates the stopped job(s). If jobid is omitted, it defaults
to the current job.
Page 2 Reliant UNIX 5.44 Printed 11/98
jsh(1) jsh(1)
fg [%jobid ...]
Resumes the execution of a stopped job in the foreground, or
moves an executing background job into the foreground. jobid
designates the job(s) to be processed. If jobid is omitted, it
defaults to the current job.
jobs [-l|-p] [%jobid ...] Format 1
jobs -x command [argument ...] Format 2
Format 1: Print information about jobs
Prints information on standard output about jobs that are stopped
or executing in the background. If jobid is omitted, all jobs
that are stopped or running in the background will be reported.
The following options modify the output of jobs:
-l Writes the process group ID and working directory of the
jobs to standard output.
-p Writes only the process group ID of the jobs to standard
output.
Format 2: Apply command to jobs
This command replaces any jobid found in command or argument with
the corresponding process group ID and then executes the result-
ing command with the resulting arguments.
kill [signal] %jobid
This is a Bourne shell built-in version of the kill command. It
provides the same functionality as the kill command, but allows
you to identify a job with a jobid instead of a process ID.
stop %jobid ...
Stops the execution of the background job(s) identified by jobid.
suspend
Stops the execution of the current jsh shell (but not if it is a
login shell).
wait [%jobid ...]
This version of the Bourne shell built-in wait accepts jobid as
an argument. If jobid is omitted, wait behaves like the normal
wait built-in; otherwise, it waits for the background job(s) to
terminate.
Page 3 Reliant UNIX 5.44 Printed 11/98
jsh(1) jsh(1)
LOCALE
The LCMESSAGES environment variable governs the language in which
message texts are displayed.
In file name generation patterns in square brackets, the LCCOLLATE
environment variable governs the scope of character ranges, equiva-
lence classes and collating elements, and the LCCTYPE environment
variable governs the scope of character classes. LCCTYPE also governs
which characters in the current character set are defined as letters.
If LCMESSAGES, LCCOLLATE or LCCTYPE is undefined or is defined as
the null string, it defaults to the value of LANG. If LANG is likewise
undefined or null, the system acts as if it were not international-
ized.
If any of the locale variables has an invalid value, the system acts
as if none of the variables were set.
EXAMPLES
The following section contains a brief example demonstrating job han-
dling in the jsh shell.
The first step is to call the shell by entering
$ jsh
To avoid confusion, it is advisable to modify the prompt:
$ PS1="jsh> "
Let us assume you now want to look for a file named test. To do this,
you run the find command in the background:
jsh> find / -name test -print &
The shell then displays job ID 1 and process ID 28071:
[1] 28071
You now print a list of all current jobs:
jsh> jobs
[1] + Running find / -name test -print
Next, you stop job number 1 (i.e. the find command):
jsh> stop %1
Page 4 Reliant UNIX 5.44 Printed 11/98
jsh(1) jsh(1)
You then again print list of all current jobs:
jsh> jobs
[1] + Stopped (signal) find / -name test -print
and resume execution of the current job (i.e. the find command) in the
background:
jsh> bg %%
The shell displays the resumed command:
[1] find / -name test -print &
You can now terminate the find job with:
jsh> kill %find
and print a fresh list of all current jobs:
jsh> jobs
[1] + Terminated find / -name test -print
Finally, you exit the jsh shell with:
jsh> exit
and return to the Bourne shell with its standard prompt:
$
SEE ALSO
sh(1).
Page 5 Reliant UNIX 5.44 Printed 11/98