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