date and time created 88/10/21 13:47:49 by bostic
[unix-history] / usr / src / old / man / newcsh.1
CommitLineData
d7bd7015
KM
1.\" Copyright (c) 1980 Regents of the University of California.
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
5.\" @(#)newcsh.1 4.1 (Berkeley) %G%
6.\"
7.TH NEWCSH 1 "4/1/81"
8.UC 4
9.bd S 3
10.SH NAME
11newcsh \- description of new csh features (over oldcsh)
12.SH SYNOPSIS
13.B csh
14\fIcsh-options\fR
15.SH SUMMARY
16This is a summary of features new in
17.IR csh (1)
18in this version of the system; an older version of
19.I csh
20is available as
21.I oldcsh.
22This newer
23.I csh
24has some new process control primitives and a few other new features.
25Users of
26.I csh
27must (and automatically) use the new terminal driver (summarized in
28.IR newtty(4)
29and completely described with the old in
30.IR tty (4))
31which allows generation of some new
32interrupt signals from the keyboard which tell jobs to stop,
33and arbitrates access to the terminal;
34on CRT's the command ``stty crt'' is
35normally placed in the
36.I .login
37file to be executed at login,
38to set other useful modes of this terminal driver.
39.PP
40.B "Jobs."
41.PP
42The most important new feature in this shell is the control of
43.I jobs.
44A job is associated with each pipeline, where a pipeline is either
45a simple command like ``date'', or a pipeline like ``who | wc''.
46The shell keeps a table of current jobs, and assigns them small
47integer numbers.
48When you start a job in the background, the shell prints a line
49which looks like:
50.PP
51\ \ \ \ [1] 1234
52.PP
53this indicating that the job which was started asynchronously with ``&''
54is job number 1 and has one (top-level) process, whose process id is 1234.
55The set of current jobs is listed by the
56.I jobs
57command.
58.PP
59If you are running a job and wish to do something else you may hit the
60key ^Z (control-Z) which sends a
61.I stop
62signal to the current job. The shell will then normally indicate that
63the job has been ``Stopped'', and print another prompt.
64You can then
65put the job in the background with the command ``bg'', or run
66some other commands and then return the job to the foreground with
67``fg''.
68A ^Z takes effect immediately and is like an interrupt in that
69pending output and unread input are discarded when it is typed.
70There is another special key ^Y which does not generate a stop signal
71until a program attempts to
72.IR read (2)
73it.
74This can usefully be typed ahead when you have prepared some commands
75for a job which you wish to stop after it has read them.
76.PP
77A job being run in the background will stop if it tries to read
78from the terminal. Background jobs are normally allowed to produce output,
79but this can be disabled by doing ``stty tostop''. If you set this
80tty option, then background jobs will stop when they try to produce
81output like they do when they try to read input.
82.PP
83There are several ways to refer to jobs in the shell. The character
84``%'' introduces a job name. If you wish to refer to job number 1, you can
85name it as ``%1''. Just naming a job brings it to the foreground; thus
86``%1'' is a synonym for ``fg %1'', bringing job 1 back into the foreground.
87Similarly saying ``%1 &'' resumes job 1 in the background.
88Jobs can also be named by prefixes of the string typed in to start them,
89if these prefixes are unambiguous, thus ``%ex'' would normally restart
90a suspended
91.IR ex (1)
92job, if there were only one suspended job whose name began with
93the string ``ex''. It is also possible to say ``%?string''
94which specifies a job whose text contains
95.I string,
96if there is only one such job.
97.PP
98The shell also maintains a notion of the current and previous jobs.
99In output pertaining to jobs, the current job is marked with a ``+''
100and the previous job with a ``\-''. The abbreviation ``%+'' refers
101to the current job and ``%\-'' refers to the previous job. For close
102analogy with the
103.I history
104mechanism,
105``%%'' is also a synonym for the current job.
106.PP
107.B "Status reporting."
108.PP
109This shell learns immediately whenever a process changes state.
110It normally informs you whenever a job becomes blocked so that
111no further progress is possible, but only just before it prints
112a prompt. This is done so that it does not otherwise disturb your work.
113If, however, you set the shell variable
114.I notify,
115the shell will notify you immediately of changes of status in background
116jobs.
117There is also a shell command
118.I notify
119which marks a single process so that its status changes will be immediately
120reported. By default
121.I notify
122marks the current process;
123simply say ``notify'' after starting a background job to mark it.
124.PP
125When you try to leave the shell while jobs are stopped, you will
126be warned that ``You have stopped jobs.'' You may use the ``jobs''
127command to see what they are. If you do this or immediately try to
128exit again, the shell will not warn you a second time, and the suspended
129jobs will be unmercifully terminated.
130.PP
131.B "New builtin commands."
132.HP 5
133.B bg
134.br
135.ns
136.HP 5
137\fBbg\ %\fRjob\ ...
138.br
139Puts the current or specified jobs into the background, continuing them
140if they were stopped.
141.HP 5
142.B fg
143.br
144.ns
145.HP 5
146\fBfg\ %\fRjob\ ...
147.br
148Brings the current or specified jobs into the foreground, continuing them if
149they were stopped.
150.HP 5
151.B jobs
152.br
153.ns
154.HP 5
155.B "jobs \-l"
156.br
157Lists the active jobs; given the
158.B \-l
159options lists process id's in addition to the normal information.
160.HP 5
161\fBkill %\fRjob
162.br
163.ns
164.HP 5
165\fBkill\ \-\fRsig\ \fB%\fRjob\ ...
166.br
167.ns
168.HP 5
169\fBkill\fR\ pid
170.br
171.ns
172.HP 5
173\fBkill\ \-\fRsig\ pid\ ...
174.br
175.ns
176.HP 5
177\fBkill\ \-l\fR
178.br
179Sends either the TERM (terminate) signal or the
180specified signal to the specified jobs or processes.
181Signals are either given by number or by names (as given in
182.I /usr/include/signal.h,
183stripped of the prefix ``SIG'').
184The signal names are listed by ``kill \-l''.
185There is no default, saying just `kill' does not
186send a signal to the current job.
187If the signal being sent is TERM (terminate) or HUP (hangup),
188then the job or process will be sent a CONT (continue) signal as well.
189.HP 5
190.B notify
191.br
192.ns
193.HP 5
194\fBnotify\ %\fRjob\ ...
195.br
196Causes the shell to notify the user asynchronously when the status of the
197current or specified jobs changes; normally notification is presented
198before a prompt. All jobs are marked ``notify'' if the shell variable
199``notify'' is set.
200.HP 5
201\fBstop\ %\fRjob\ ...
202.br
203Stops the specified job which is executing in the background.
204.HP 5
205\fB%\fRjob
206.br
207Brings the specified job into the foreground.
208.HP 5
209\fB%\fRjob \fB&\fR
210.br
211Continues the specified job in the background.
212.br
213.ne 5
214.PP
215.B "Process limitations."
216.PP
217The shell provides access to an experimental facility for limiting
218the consumption by a single process of system resources.
219The following commands control this facility:
220.HP 5
221\fBlimit\fR \fIresource\fR \fImaximum-use\fR
222.HP 5
223\fBlimit\fR \fIresource\fR
224.br
225.ns
226.HP
227\fBlimit\fR
228.br
229Limits the consumption by the current process and each process
230it creates to not individually exceed \fImaximum-use\fR on the
231specified \fIresource\fR. If no \fImaximum-use\fR is given, then
232the current limit is printed; if no \fIresource\fR is given, then
233all limitations are given.
234.IP
235Resources controllable currently include \fIcputime\fR (the maximum
236number of cpu-seconds to be used by each process), \fIfilesize\fR
237(the largest single file which can be created), \fIdatasize\fR
238(the maximum growth of the data+stack region via
239.IR sbrk (2)
240beyond the end of the program text), \fIstacksize\fR (the maximum
241size of the automatically-extended stack region), and \fIcoredumpsize\fR
242(the size of the largest core dump that will be created).
243.IP
244The \fImaximum-use\fR may be given as a (floating point or integer)
245number followed by a scale factor. For all limits other than \fIcputime\fR
246the default scale is ``k'' or ``kilobytes'' (1024 bytes);
247a scale factor of ``m'' or ``megabytes'' may also be used.
248For cputime the default scaling is ``seconds'', while ``m'' for minutes
249or ``h'' for hours, or a time of the form ``mm:ss'' giving minutes
250and seconds may be used.
251.IP
252For both \fIresource\fR names and scale factors, unambiguous prefixes
253of the names suffice.
254.HP 5
255\fBunlimit\fR \fIresource\fR
256.br
257.ns
258.HP 5
259\fBunlimit\fR
260.br
261Removes the limitation on \fIresource\fR. If no \fIresource\fR
262is specified, then all \fIresource\fR limitations are removed.
263.ne 5
264.PP
265.B "Directory stack."
266.PP
267This shell now keeps track of the current directory (which is kept
268in the variable
269.I cwd)
270and also maintains a stack of directories, which is printed by the
271command
272.I dirs.
273You can change to a new directory and push down the old directory
274stack by using the command
275.I pushd
276which is otherwise like the
277.I chdir
278command, changing to its argument.
279You can pop the directory stack by saying
280.I popd.
281Saying
282.I pushd
283with no arguments exchanges the top two elements of the directory stack.
284The elements of the directory stack are numbered from 1 starting at the top.
285Saying
286.I pushd
287with a argument ``+\fIn\fR'' rotates the directory stack to make that entry
288in the stack be at the top and changes to it.
289Giving
290.I popd
291a ``+\fIn\fR'' argument eliminates that argument from the directory stack.
292.PP
293.B "Miscellaneous."
294.PP
295This shell imports the environment variable USER into the variable
296.I user,
297TERM into
298.I term,
299and
300HOME into
301.I home,
302and exports these back into the environment whenever the normal
303shell variables are reset.
304The environment variable PATH is likewise handled; it is not
305necessary to worry about its setting other than in the file
306.I \&.cshrc
307as inferior
308.I csh
309processes will import the definition of
310.I path
311from the environment, and re-export it if you then change it.
312(It could be set once in the
313.I \&.login
314except that commands over the Berknet would not
315see the definition.)
316.PP
317There are new commands
318.I eval,
319which is like the eval of the Bourne shell
320.IR sh (1),
321and useful with
322.IR tset (1),
323and
324.I suspend
325which stops a shell (as though a ^Z had stopped it; since
326shells normally ignore ^Z signals, this command is necessary.)
327.PP
328There is a new variable
329.I cdpath;
330if set, then each directory in
331.I cdpath
332will be searched for a directory named in a
333.I chdir
334command if there is no such subdirectory of the current directory.
335.PP
336An
337.I unsetenv
338command removing environment variables has been added.
339.PP
340There is a new ``:'' modifier ``:e'', which yields the extension
341portion of a filename. Thus if ``$a'' is ``file.c'', ``$a:e'' is ``c''.
342.PP
343There are two new operators in shell expressions ``!~'' and ``=~'' which
344are like the string operations ``!='' and ``=='' except that the right
345hand side is a
346.I pattern
347(containing, e.g. ``*''s, ``?''s and instances of ``[...]'')
348against which the left hand operand is matched. This reduces the
349need for use of the
350.I switch
351statement in shell scripts when all that is really needed is pattern matching.
352.PP
353The form ``$<'' is new, and is replaced by a line from the standard
354input, with no further interpretation thereafter. It may therefore
355be used to read from the keyboard in a shell script.
356.SH "SEE ALSO"
357csh(1), killpg(2), sigsys(2), signal(2), jobs(3), sigset(3), tty(4)
358.SH BUGS
359Command sequences of the form ``a ; b ; c'' are not handled gracefully
360when stopping is attempted. If you suspend ``b'', the shell will then
361immediately execute ``c''. This is especially noticeable if this
362expansion results from an
363.I alias.
364It suffices to place the sequence of commands in ()'s to force it to
365a subshell, i.e. ``( a ; b ; c )'', but see the next bug.
366.PP
367Shell builtin functions are not stoppable/restartable.
368.PP
369Control over output is primitive;
370perhaps this will inspire someone to work on a good virtual
371terminal interface. In a virtual terminal interface much more
372interesting things could be done with output control.